Part Number Hot Search : 
LA000 CLAMP FL20S FL20S AME88 2SJ244 ST485 20M00
Product Description
Full Text Search
 

To Download TMP89FM42 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
 8 Bit Microcontroller
TLCS-870/C1 Series
TMP89FM42
The information contained herein is subject to change without notice. 021023_D TOSHIBA is continually working to improve the quality and reliability of its products. Nevertheless, semiconductor devices in general can malfunction or fail due to their inherent electrical sensitivity and vulnerability to physical stress. It is the responsibility of the buyer, when utilizing TOSHIBA products, to comply with the standards of safety in making a safe design for the entire system, and to avoid situations in which a malfunction or failure of such TOSHIBA products could cause loss of human life, bodily injury or damage to property. In developing your designs, please ensure that TOSHIBA products are used within specified operating ranges as set forth in the most recent TOSHIBA products specifications. Also, please keep in mind the precautions and conditions set forth in the "Handling Guide for Semiconductor Devices," or "TOSHIBA Semiconductor Reliability Handbook" etc. 021023_A The TOSHIBA products listed in this document are intended for usage in general electronics applications (computer, personal equipment, office equipment, measuring equipment, industrial robotics, domestic appliances, etc.). These TOSHIBA products are neither intended nor warranted for usage in equipment that requires extraordinarily high quality and/or reliability or a malfunction or failure of which may cause loss of human life or bodily injury ("Unintended Usage"). Unintended Usage include atomic energy control instruments, airplane or spaceship instruments, transportation instruments, traffic signal instruments, combustion control instruments, medical instruments, all types of safety devices, etc. Unintended Usage of TOSHIBA products listed in this document shall be made at the customer's own risk. 021023_B The products described in this document shall not be used or embedded to any downstream products of which manufacture, use and/or sale are prohibited under any applicable laws and regulations. 060106_Q The information contained herein is presented only as a guide for the applications of our products. No responsibility is assumed by TOSHIBA for any infringements of patents or other rights of the third parties which may result from its use. No license is granted by implication or otherwise under any patents or other rights of TOSHIBA or the third parties. 070122_C The products described in this document are subject to foreign exchange and foreign trade control laws. 060925_E For a discussion of how the reliability of microcontrollers can be predicted, please refer to Section 1.3 of the chapter entitled Quality and Reliability Assurance/Handling Precautions. 030619_S
(c) 2007 TOSHIBA CORPORATION All Rights Reserved
Revision History
Date 2007/10/25 2007/11/3 Revision 1 2 First Release Contents Revised
Table of Contents
TMP89FM42
1.1 1.2 1.3 1.4 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Pin Assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Pin Names and Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 3 4 5
2. CPU Core
2.1 2.2 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Memory space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Code area ................................................................................................................................................. 9
RAM BOOTROM Flash SFR RAM BOOTROM Flash 2.2.1.1 2.2.1.2 2.2.1.3 2.2.2.1 2.2.2.2 2.2.2.3 2.2.2.4
2.2.1
2.2.2
Data area ................................................................................................................................................ 12
2.3
System clock controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Configuration .......................................................................................................................................... 15 Control .................................................................................................................................................... 15 Functions ................................................................................................................................................ 17
Clock generator Clock gear Timing generator
2.3.1 2.3.2 2.3.3
2.3.4 2.3.5
2.3.3.1 2.3.3.2 2.3.3.3 2.3.4.1 2.3.4.2 2.3.5.1 2.3.5.2 2.3.5.3 2.3.5.4 2.3.6.1 2.3.6.2 2.3.6.3 2.3.6.4
Warm-up counter .................................................................................................................................... 20 Operation mode control circuit ................................................................................................................ 22
Single-clock mode Dual-clock mode STOP mode Transition of operation modes STOP mode IDLE1/2 and SLEEP1 modes IDLE0 and SLEEP0 modes SLOW mode Warm-up counter operation when the oscillation is enabled by the hardware Warm-up counter operation when the oscillation is enabled by the software
2.3.6
Operation Mode Control ......................................................................................................................... 27
2.4
Reset Control Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Configuration .......................................................................................................................................... Control .................................................................................................................................................... Functions ................................................................................................................................................ Reset Signal Generating Factors............................................................................................................
External reset input (RESET pin input) Power-on reset Voltage detection reset Watchdog timer reset System clock reset Trimming data reset Flash standby reset Internal factor reset detection status register How to use the external reset input pin as a port
2.4.1 2.4.2 2.4.3 2.4.4
38 38 40 41
2.5
2.4.4.1 2.4.4.2 2.4.4.3 2.4.4.4 2.4.4.5 2.4.4.6 2.4.4.7 2.4.4.8 2.4.4.9
Revision History. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
i
3. Interrupt Control Circuit
3.1 3.2 3.3 3.4 3.5 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 Interrupt Latches (IL25 to IL3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 Interrupt Enable Register (EIR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 Maskable Interrupt Priority Change Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 Interrupt Sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Initial Setting ........................................................................................................................................... 56 Interrupt acceptance processing............................................................................................................. 56 Saving/restoring general-purpose registers ............................................................................................ 57
Using PUSH and POP instructions Using data transfer instructions Using a register bank to save/restore general-purpose registers
3.3.1 3.3.2
Interrupt master enable flag (IMF) .......................................................................................................... 51 Individual interrupt enable flags (EF25 to EF4) ...................................................................................... 51
3.5.1 3.5.2 3.5.3
3.6
3.5.4 3.6.1 3.6.2
3.5.3.1 3.5.3.2 3.5.3.3
Software Interrupt (INTSW) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 Undefined Instruction Interrupt (INTUNDEF). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 Revision History. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
Address error detection .......................................................................................................................... 60 Debugging .............................................................................................................................................. 60
Interrupt return ........................................................................................................................................ 59
3.7 3.8
4. External Interrupt control circuit
4.1 4.2 4.3 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 Function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Low power consumption function ........................................................................................................... 67 External interrupt 0 ................................................................................................................................. 68 External interrupts 1/2/3.......................................................................................................................... 68
Interrupt request signal generating condition detection function A noise canceller pass signal monitoring function when interrupt request signals are generated Noise cancel time selection function Interrupt request signal generating condition detection function A noise canceller pass signal monitoring function when interrupt request signals are generated Noise cancel time selection function
4.3.1 4.3.2 4.3.3
4.3.4
4.3.3.1 4.3.3.2 4.3.3.3 4.3.4.1 4.3.4.2 4.3.4.3
External interrupt 4 ................................................................................................................................. 69
4.3.5
External interrupt 5 ................................................................................................................................. 71
5. Watchdog Timer (WDT)
5.1 5.2 5.3 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Setting of enabling/disabling the watchdog timer operation ................................................................... Setting the clear time of the 8-bit up counter .......................................................................................... Setting the overflow time of the 8-bit up counter .................................................................................... Setting an overflow detection signal of the 8-bit up counter ................................................................... Writing the watchdog timer control codes ............................................................................................... Reading the 8-bit up counter .................................................................................................................. Reading the watchdog timer status ........................................................................................................ 75 76 76 77 77 78 78
5.3.1 5.3.2 5.3.3 5.3.4 5.3.5 5.3.6 5.3.7
6. Power-on Reset Circuit
6.1 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
ii
6.2
Function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
7. Voltage Detection Circuit
7.1 7.2 7.3 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 Function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
Enabling/disabling the voltage detection operation ................................................................................ Selecting the voltage detection operation mode ..................................................................................... Selecting the detection voltage level ...................................................................................................... Voltage detection flag and voltage detection status flag......................................................................... Selecting the STOP mode release signal ............................................................................................... 83 83 83 83 84
7.4 7.5
7.3.1 7.3.2 7.3.3 7.3.4 7.3.5 7.4.1 7.4.2
Register Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 Revision History. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Setting procedure when the operation mode is set to generate voltage detection interrupt request signals 85 Setting procedure when the operation mode is set to generate voltage detection reset signals ............ 85
8. I/O Ports
8.1 8.2 8.3 I/O Port Control Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 List of I/O Port Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 I/O Port Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
Port P0 (P03 to P00)............................................................................................................................... 94 Port P1 (P13 to P10)............................................................................................................................... 98 Port P2 (P27 to P20)............................................................................................................................. 101 Port P4 (P47 to P40)............................................................................................................................. 105 Port P7 (P77 to P70)............................................................................................................................. 108 Port P8 (P81 to P80)............................................................................................................................. 110 Port P9 (P91 to P90)............................................................................................................................. 113 Port PB (PB7 to PB4) ........................................................................................................................... 116
8.4 8.5
8.3.1 8.3.2 8.3.3 8.3.4 8.3.5 8.3.6 8.3.7 8.3.8
Serial Interface Selecting Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 Revision History. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
9. Special Function Registers
9.1 9.2 9.3 SFR1 (0x0000 to 0x003F) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 SFR2 (0x0F00 to 0x0FFF). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 SFR3 (0x0E40 to 0x0EFF) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
10. Low Power Consumption Function for Peripherals
10.1 Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
11. Divider Output (DVO)
11.1 11.2 11.3 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 Revision History. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
Function .............................................................................................................................................. 133
11.2.1
iii
12. Time Base Timer (TBT)
12.1 Time Base Timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
Configuration ...................................................................................................................................... 137 Control ................................................................................................................................................ 137 Functions ............................................................................................................................................ 138 12.1.1 12.1.2 12.1.3
12.2
Revision History. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
13. 16-bit Timer Counter (TCA)
13.1 13.2 13.3 13.4 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Low Power Consumption Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Timer Function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Timer mode......................................................................................................................................... 148
Setting Operation Auto capture Register buffer configuration Setting Operation Auto capture Register buffer configuration Setting Operation Auto capture Register buffer configuration Setting Operation Auto capture Register buffer configuration Setting Operation 13.4.1.1 13.4.1.2 13.4.1.3 13.4.1.4 13.4.2.1 13.4.2.2 13.4.2.3 13.4.2.4 13.4.3.1 13.4.3.2 13.4.3.3 13.4.3.4 13.4.4.1 13.4.4.2 13.4.4.3 13.4.4.4 13.4.5.1 13.4.5.2 13.4.6.1 13.4.6.2 13.4.6.3
142 143 147 148
13.4.1
13.4.2
External trigger timer mode ................................................................................................................ 152
13.4.3
Event counter mode............................................................................................................................ 154
13.4.4
Window mode ..................................................................................................................................... 156
13.4.5 13.4.6
Pulse width measurement mode ........................................................................................................ 158 Programmable pulse generate (PPG) mode ...................................................................................... 160
Setting Operation Register buffer configuration
13.5 13.6
Noise Canceller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 Revision History. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
Setting................................................................................................................................................. 163
13.5.1
14. 8-bit Timer Counter (TC0)
14.1 14.2 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166 Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
Timer counter 00................................................................................................................................. Timer counter 01................................................................................................................................. Common to timer counters 00 and 01 ................................................................................................ Operation modes and usable source clocks ....................................................................................... 167 169 171 173
14.3 14.4
14.2.1 14.2.2 14.2.3 14.2.4
Low Power Consumption Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
8-bit timer mode .................................................................................................................................. 175
Setting Operation Double buffer Setting
14.4.1
14.4.2
14.4.1.1 14.4.1.2 14.4.1.3 14.4.2.1
8-bit event counter mode .................................................................................................................... 178
iv
14.4.3
14.4.2.2 14.4.2.3 14.4.3.1 14.4.3.2 14.4.3.3 14.4.4.1 14.4.4.2 14.4.4.3 14.4.5.1 14.4.5.2 14.4.5.3 14.4.6.1 14.4.6.2 14.4.6.3 14.4.7.1 14.4.7.2 14.4.7.3 14.4.8.1 14.4.8.2 14.4.8.3
8-bit pulse width modulation (PWM) output mode .............................................................................. 180
Setting Operations Double buffer Setting Operation Double buffer Setting Operations Double buffer Setting Operations Double buffer Setting Operations Double buffer Setting Operations Double buffer
Operation Double buffer
14.4.4
8-bit programmable pulse generate (PPG) output mode .................................................................... 185
14.4.5
16-bit timer mode ................................................................................................................................ 188
14.4.6
16-bit event counter mode .................................................................................................................. 192
14.4.7
12-bit pulse width modulation (PWM) output mode ............................................................................ 194
14.4.8
16-bit programmable pulse generate (PPG) output mode .................................................................. 200
15. Real Time Clock (RTC)
15.1 15.2 15.3 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
Low Power Consumption Function ..................................................................................................... 204 Enabling/disabling the real time clock operation................................................................................. 204 Selecting the interrupt generation interval .......................................................................................... 204
15.4
15.3.1 15.3.2 15.3.3 15.4.1 15.4.2
Real Time Clock Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
Enabling the real time clock operation ................................................................................................ 205 Disabling the real time clock operation ............................................................................................... 205
16. Asynchronous Serial Interface (UART)
16.1 16.2 16.3 16.4 16.5 16.6 16.7 16.8 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 Low Power Consumption Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 Protection to Prevent UART0CR1 and UART0CR2 Registers from Being Changed 214 Activation of STOP, IDLE0 or SLEEP0 Mode . . . . . . . . . . . . . . . . . . . . . . . . . . 215 Transfer Data Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216 Infrared Data Format Transfer Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216 Transfer Baud Rate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
Transfer baud rate calculation method ............................................................................................... 218
Bit width adjustment using UART0CR2 Calculation of set values of UART0CR2 and UART0DR
16.5.1 16.5.2
Transition of register status ................................................................................................................ 215 Transition of TXD pin status ............................................................................................................... 215
16.8.1
16.9 Data Sampling Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221 16.10 Received Data Noise Rejection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223 16.11 Transmit/Receive Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224 16.12
16.11.1 16.11.2
16.8.1.1 16.8.1.2
Status Flag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
Data transmit operation .................................................................................................................... 224 Data receive operation...................................................................................................................... 224
v
16.13 16.14 16.15
16.12.1 16.12.2 16.12.3 16.12.4 16.12.5 16.12.6
Receiving Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232 AC Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234 Revision History. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
IrDA properties.................................................................................................................................. 234
Parity error ........................................................................................................................................ Framing Error.................................................................................................................................... Overrun error .................................................................................................................................... Receive Data Buffer Full................................................................................................................... Transmit busy flag ........................................................................................................................... Transmit Buffer Full ..........................................................................................................................
225 226 227 230 231 231
16.14.1
17. Synchronous Serial Interface (SIO)
17.1 17.2 17.3 17.4 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Low Power Consumption Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Transfer format ................................................................................................................................... 243 Serial clock ......................................................................................................................................... 243 Transfer edge selection ...................................................................................................................... 243 8-bit transmit mode ............................................................................................................................. 245
Setting Starting the transmit operation Transmit buffer and shift operation Operation on completion of transmission Stopping the transmit operation Setting Starting the receive operation Operation on completion of reception Stopping the receive operation
238 239 242 243
17.5
17.4.1 17.4.2 17.4.3 17.5.1
Transfer Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
17.5.2
17.5.1.1 17.5.1.2 17.5.1.3 17.5.1.4 17.5.1.5 17.5.2.1 17.5.2.2 17.5.2.3 17.5.2.4 17.5.3.1 17.5.3.2 17.5.3.3 17.5.3.4 17.5.3.5
8-bit Receive Mode ............................................................................................................................. 250
17.5.3
8-bit transmit/receive mode ................................................................................................................ 254
Setting Starting the transmit/receive operation Transmit buffer and shift operation Operation on completion of transmission/reception Stopping the transmit/receive operation
17.6 17.7
AC Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259 Revision History. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
18. Serial Bus Interface (SBI)
18.1 18.2 18.3 18.4 Communication Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263 Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
I2C bus ............................................................................................................................................... 261 Free data format ................................................................................................................................. 262 18.1.1 18.1.2
18.4.1 Low Power Consumption Function ..................................................................................................... 267 18.4.2 Selecting the slave address match detection and the GENERAL CALL detection............................. 268 18.4.3 Selecting the number of clocks for data transfer and selecting the acknowledgement or non-acknowledgment mode ........................................................................................................................................................... 268 18.4.4 18.4.5 18.4.6 18.4.7
18.4.3.1 18.4.3.2 18.4.4.1 18.4.4.2
Serial clock ......................................................................................................................................... 270
Clock source Clock synchronization
Number of clocks for data transfer Output of an acknowledge signal
Master/slave selection ........................................................................................................................ 272 Transmitter/receiver selection............................................................................................................. 272 Start/stop condition generation ........................................................................................................... 273
vi
18.5
18.4.8 Interrupt service request and release ................................................................................................. 18.4.9 Setting of serial bus interface mode ................................................................................................... 18.4.10 Software reset................................................................................................................................... 18.4.11 Arbitration lost detection monitor ...................................................................................................... 18.4.12 Slave address match detection monitor............................................................................................ 18.4.13 GENERAL CALL detection monitor .................................................................................................. 18.4.14 Last received bit monitor................................................................................................................... 18.4.15 Slave address and address recognition mode specification ............................................................. 18.5.1 18.5.2 18.5.3 18.5.4 18.5.5
Data Transfer of I2C Bus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
Device initialization ............................................................................................................................. 278 Start condition and slave address generation..................................................................................... 278 1-word data transfer............................................................................................................................ 279 Stop condition generation ................................................................................................................... 283 Restart ................................................................................................................................................ 283
When SBI0SR2 is "1" (Master mode) When SBI0SR2 is "0" (Slave mode)
274 274 274 275 276 277 277 277
18.5.3.1 18.5.3.2
18.6 18.7
AC Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285 Revision History. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
19. Key-on Wakeup (KWU)
19.1 19.2 19.3 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289 Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
20. 10-bit AD Converter (ADC)
20.1 20.2 20.3 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
Single mode........................................................................................................................................ 298 Repeat mode ...................................................................................................................................... 298 AD operation disable and forced stop of AD operation....................................................................... 299
20.4 20.5 20.6 20.7
20.3.1 20.3.2 20.3.3
Register Setting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Starting STOP/IDLE0/SLOW Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Analog Input Voltage and AD Conversion Result . . . . . . . . . . . . . . . . . . . . . . . Precautions about the AD Converter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Analog input pin voltage range ........................................................................................................... 302 Analog input pins used as input/output ports ...................................................................................... 302 Noise countermeasure........................................................................................................................ 302
300 300 301 302
20.7.1 20.7.2 20.7.3
21. Flash Memory
21.1 21.2 Flash Memory Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
Flash memory command sequence execution and toggle control (FLSCR1 ) ................... Flash memory area switching (FLSCR1)............................................................................ RAM area switching (SYSCR3).......................................................................................... BOOTROM area switching (FLSCR1)................................................................................ Flash memory standby control (FLSSTB) ............................................................................. Port input control register (SPCR) ................................................................................ 307 308 309 309 310 311
21.3
21.2.1 21.2.2 21.2.3 21.2.4 21.2.5 21.2.6 21.3.1 21.3.2 21.3.3
Command Sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312
Byte program ...................................................................................................................................... 312 Sector erase (4-kbyte partial erase) ................................................................................................... 313 Chip erase (all erase) ......................................................................................................................... 313
vii
21.4 21.5
21.3.4 21.3.5 21.3.6
Toggle Bit (D6) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314 Access to the Flash Memory Area. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
Flash memory control in serial PROM mode ...................................................................................... 315 Flash memory control in MCU mode .................................................................................................. 318
How to write to the flash memory by transferring a control program to the RAM area How to write to the flash memory by using a support program (API) of BOOTROM How to transfer and write a control program to the RAM area in RAM loader mode of the serial PROM mode
Product ID entry .................................................................................................................................. 314 Product ID exit .................................................................................................................................... 314 Security program ................................................................................................................................ 314
21.5.1 21.5.2
21.5.1.1 21.5.2.1 21.5.2.2
21.6
Revision History. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323
22. Serial PROM Mode
22.1 22.2 22.3 22.4 22.5 22.6 22.7 22.8 Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325 Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325 Serial PROM Mode Setting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326 Example Connection for On-board Writing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328 Activating the Serial PROM Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329 Interface Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330 Memory Mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332 Operation Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332
Flash memory erase command (0xF0) ............................................................................................... 335
Specifying the erase area
22.3.1
Serial PROM mode control pins ......................................................................................................... 326
22.6.1 22.6.2
SIO communication ............................................................................................................................ 330 UART communication ......................................................................................................................... 330
22.8.1 22.8.2 22.8.3 22.8.4 22.8.5 22.8.6 22.8.7 22.8.8 22.8.9
22.8.1.1
Flash memory write command (operation command: 0x30)............................................................... Flash memory read command (operation command: 0x40) ............................................................... RAM loader command (operation command: 0x60) ........................................................................... Flash memory SUM output command (operation command: 0x90) ................................................... Product ID code output command (operation command: 0xC0)......................................................... Flash memory status output command (0xC3) ...................................................................................
Flash memory status code
338 340 342 344 345 347
22.8.7.1
22.9 Error Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352 22.10 Checksum (SUM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353 22.11 22.12
22.10.1 22.10.2
Mask ROM emulation setting command (0xD0) ................................................................................. 350 Flash memory security setting command (0xFA)................................................................................ 351
Intel Hex Format (Binary) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354 Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355
Passwords ........................................................................................................................................ 355
How a password can be specified Password structure Password setting, cancellation and authentication Password values and setting range How the security program functions Enabling or disabling the security program
Calculation method ........................................................................................................................... 353 Calculation data ................................................................................................................................ 353
22.12.1
22.12.2
22.12.1.1 22.12.1.2 22.12.1.3 22.12.1.4 22.12.2.1 22.12.2.2
Security program .............................................................................................................................. 359
22.13 22.14
22.12.3 22.12.4
Flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363 AC Characteristics (UART) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364
Reset timing ...................................................................................................................................... Flash memory erase command (0xF0) ............................................................................................. Flash memory write command (0x30)............................................................................................... Flash memory read command (0x40) ............................................................................................... RAM loader command (0x60) ........................................................................................................... Flash memory SUM output command (0x90) ................................................................................... 365 365 366 366 367 367
Option codes..................................................................................................................................... 360 Recommended settings .................................................................................................................... 362
22.14.1 22.14.2 22.14.3 22.14.4 22.14.5 22.14.6
viii
22.15
22.14.7 Product ID code output command (0xC0) ........................................................................................ 22.14.8 Flash memory status output command (0xC3) ................................................................................. 22.14.9 Mask ROM emulation setting command (0xD0) ............................................................................... 22.14.10 Flash memory security setting command (0xFA)............................................................................
Revision History. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369
367 368 368 368
23. On-chip Debug Function (OCD)
23.1 23.2 23.3 23.4 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Control Pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . How to Connect the On-chip Debug Emulator to a Target System . . . . . . . . . . Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371 371 372 372
24. Input/Output Circuit
24.1 Control Pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373
25. Electrical Characteristics
25.1 25.2 Absolute Maximum Ratings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375 Operating Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376
MCU mode (Flash Programming or erasing) ...................................................................................... 376 MCU mode (Except Flash Programming or erasing) .......................................................................... 377 Serial PROM mode ............................................................................................................................. 378
25.3 25.4 25.5 25.6 25.7
25.2.1 25.2.2 25.2.3
DC Characteristics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . AD Conversion Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Power-on Reset Circuit Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Voltage Detecting Circuit Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . AC Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
MCU mode (Flash programming or erasing) ...................................................................................... 385 MCU mode (Except Flash Programming or erasing) .......................................................................... 385 Serial PROM mode ............................................................................................................................. 386
379 382 383 384 385
25.8
25.7.1 25.7.2 25.7.3 25.8.1
Flash Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 386
Write characteristics ........................................................................................................................... 386
25.9 Recommended Oscillating Condition- 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387 25.10 Handling Precaution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 388 25.11 Revision History. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389
26. Package Dimensions
ix
x
TMP89FM42
CMOS 8-Bit Microcontroller
TMP89FM42
The TMP89FM42 is a single-chip 8-bit high-speed and high-functionality microcomputer incorporating 32768 bytes of Flash Memory. It is pin-compatible with the TMP89CM42 (Mask ROM version). The TMP89FM42 can realize operations equivalent to those of the TMP89CM42 by programming the on-chip Flash Memory.
Product No. TMP89FM42UG Note : ROM (Flash) 32768 bytes RAM 2048 bytes Package LQFP44-P-1010-0.80B Flash MCU * TMP89CM42UG Emulation Chip * TMP89C900XBG
* ; Under development
1.1 Features
1. 8-bit single chip microcomputer TLCS-870/C1 series - Instruction execution time : 100 ns (at 10 MHz) 122 s (at 32.768 kHz) - 133 types & 732 basic instructions 2. 25 interrupt sources (External : 6 Internal : 19 , Except reset) 3. Input / Output ports (40 pins)
Note : Two of above pins can not be used for the I/O port, because they should be connected with the high frequency OSC input.
Large current output: 8 pins (Typ. 20mA) 4. Watchdog timer - Interrupt or reset can be selected by the program. 5. Power-on reset circuit 6. Voltage detection circuit 7. Divider output function 8. Time base timer 9. 16-bit timer counter : 2 ch - Timer, External trigger, Event Counter, Window, Pulse width measurement, PPG OUTPUT modes
This product uses the Super Flash(R) technology under the licence of Silicon Storage Technology, Inc. Super Flash(R) is registered trademark of Silicon Storage Technology, Inc.
* The information contained herein is subject to change without notice. 021023_D * TOSHIBA is continually working to improve the quality and reliability of its products. Nevertheless, semiconductor devices in general can malfunction or fail due to their inherent electrical sensitivity and vulnerability to physical stress. It is the responsibility of the buyer, when utilizing TOSHIBA products, to comply with the standards of safety in making a safe design for the entire system, and to avoid situations in which a malfunction or failure of such TOSHIBA products could cause loss of human life, bodily injury or damage to property. In developing your designs, please ensure that TOSHIBA products are used within specified operating ranges as set forth in the most recent TOSHIBA products specifications. Also, please keep in mind the precautions and conditions set forth in the "Handling Guide for Semiconductor Devices," or "TOSHIBA Semiconductor Reliability Handbook" etc. 021023_A * The TOSHIBA products listed in this document are intended for usage in general electronics applications (computer, personal equipment, office equipment, measuring equipment, industrial robotics, domestic appliances, etc.). These TOSHIBA products are neither intended nor warranted for usage in equipment that requires extraordinarily high quality and/or reliability or a malfunction or failure of which may cause loss of human life or bodily injury ("Unintended Usage"). Unintended Usage include atomic energy control instruments, airplane or spaceship instruments, transportation instruments, traffic signal instruments, combustion control instruments, medical instruments, all types of safety devices, etc. Unintended Usage of TOSHIBA products listed in this document shall be made at the customer's own risk. 021023_B * The products described in this document shall not be used or embedded to any downstream products of which manufacture, use and/or sale are prohibited under any applicable laws and regulations. 060106_Q * The information contained herein is presented only as a guide for the applications of our products. No responsibility is assumed by TOSHIBA for any infringements of patents or other rights of the third parties which may result from its use. No license is granted by implication or otherwise under any patents or other rights of TOSHIBA or the third parties. 070122_C * The products described in this document are subject to foreign exchange and foreign trade control laws. 060925_E * For a discussion of how the reliability of microcontrollers can be predicted, please refer to Section 1.3 of the chapter entitled Quality and Reliability Assurance/Handling Precautions. 030619_S
RA000
Page 1
1.1 Features
TMP89FM42
10. 8-bit timer counter: 4 ch - Timer, Event Counter, PWM, PPG OUTPUT modes - Usable as a 16-bit timer, 12-bit PWM output and 16-bit PPG output by the cascade connection of two channels. 11. Real time clock 12. UART : 1ch 13. UART/SIO : 1ch Note : One SIO channel can be used at the same time. 14. I2C/SIO : 1ch 15. Key-on wake-up : 8 ch 16. 10-bit successive approximation type AD converter - Analog input : 8ch 17. On-chip debug function - Break/Event - Trace - RAM monitor - Flash memory writing 18. Clock operation mode control circuit : 2 circuit Single clock mode / Dual clock mode 19. Low power consumption operation (8 mode) - STOP mode: Oscillation stops. (Battery/Capacitor back-up.) - SLOW1 mode: Low power consumption operation using low-frequency clock.(High-frequency clock stop.) - SLOW2 mode: Low power consumption operation using low-frequency clock.(High-frequency clock oscillate.) - IDLE0 mode: CPU stops, and only the Time-Based-Timer(TBT) on peripherals operate using high frequency clock. Released when the reference time set to TBT has elapsed. - IDLE1 mode: The CPU stops, and peripherals operate using high frequency clock. Release by interruputs(CPU restarts). - IDLE2 mode: CPU stops and peripherals operate using high and low frequency clock. Release by interruputs. (CPU restarts). - SLEEP0 mode: CPU stops, and only the Time-Based-Timer(TBT) on peripherals operate using low frequency clock. Released when the reference time set to TBT has elapsed. - SLEEP1 mode: CPU stops, and peripherals operate using low frequency clock. Release by interruput.(CPU restarts). 20. Wide operation voltage:
4.3 V to 5.5 V at 10MHz /32.768 kHz 2.7 V to 5.5 V at 4.2 MHz /32.768 kHz 2.2 V to 5.5 V at 2MHz /32.768 kHz
RA000
Page 2
TMP89FM42
1.2 Pin Assignment
Figure 1-1 Pin Assignment
RA000
VSS (XIN) P00 (XOUT) P01 MODE VDD (XTIN) P02 (XTOUT) P03 (RESET) P10 (STOP/INT5) P11 (INT0) P12 (INT1) P13
1 2 3 4 5 6 7 8 9 10 11
(TXD1/RXD1) P91 (PWM02/PPG02/TC02) P80 (PWM03/PPG03/TC03) P81 (PWM00/PPG00/TC00) P70 (PWM01/PPG01/TC01) P71 (PPGA0/TCA0) P72 (PPGA1/TCA1) P73 (SO0/RXD0/TXD0) PB4 (SI0/TXD0/RXD0) PB5 (SCLK0) PB6 PB7
33 32 31 30 29 28 27 26 25 24 23
P90 (TXD1/RXD1) P77 (INT4) P76 (INT3) P75 (INT2) P74 (DVO) P47 (AIN7/KWI7) P46 (AIN6/KWI6) P45 (AIN5/KWI5) P44 (AIN4/KWI4) P43 (AIN3/KWI3) P42 (AIN2/KWI2)
22 21 20 19 18 17 16 15 14 13 12
34 35 36 37 38 39 40 41 42 43 44
P41(AIN1/KWI1) P40(AIN0/KWI0) VAREF/AVDD P27 P26 P25(SCLK0) P24(SCL0/SI0) P23(SDA0/SO0) P22(SCLK0) P21(RXD0/TXD0/SI0/OCDIO) P20(TXD0/RXD0/SO0/OCDCK)
Page 3
1.3 Block Diagram
TMP89FM42
1.3 Block Diagram
Figure 1-2 Block Diagram
RA000
Page 4
TMP89FM42
1.4 Pin Names and Functions
The TMP89FM42 has MCU mode, parallel PROM mode, and serial PROM mode. Table 1-1 shows the pin functions in MCU mode. The serial PROM mode is explained later in a separate chapter. Table 1-1 Pin Names and Functions(1/3)
Pin Name P03 XTOUT P02 XTIN P01 XOUT P00 XIN P13 INT1 P12
INT0
Input/Output IO O IO I IO O IO I IO I IO I IO I I IO I IO IO IO IO IO IO I IO IO O IO IO IO I O I IO IO O I O I IO I I IO I I
Functions PORT03 Low frequency OSC output PORT02 Low frequency OSC input PORT01 High frequency OSC output PORT00 High frequency OSC input PORT13 External interrupt 1 input PORT12 External interrupt 0 input PORT11 External interrupt 5 input STOP mode release input PORT10 Reset signal input PORT27 PORT26 PORT25 Serial clock input/output 0 PORT24 I2C bus clock input/output 0 Serial data input 0 PORT23 I2C bus data input/output 0 Serial data output 0 PORT22 Serial clock input/output 0 PORT21 UART data input 0 UART data output 0 Serial data input 0 OCD data input/output PORT20 UART data output 0 UART data input 0 Serial data output 0 OCD clock input PORT47 Analog input 7 Key-on wake-up input 7 PORT46 Analog input 6 Key-on wake-up input 6
P11
INT5 STOP
P10
RESET
P27 P26 P25 SCLK0 P24 SCL0 SI0 P23 SDA0 SO0 P22 SCLK0 P21 RXD0 TXD0 SI0 OCDIO P20 TXD0 RXD0 SO0 OCDCK P47 AIN7 KWI7 P46 AIN6 KWI6
RA000
Page 5
1.4 Pin Names and Functions
TMP89FM42
Table 1-1 Pin Names and Functions(2/3)
Pin Name P45 AIN5 KWI5 P44 AIN4 KWI4 P43 AIN3 KWI3 P42 AIN2 KWI2 P41 AIN1 KWI1 P40 AIN0 KWI0 P77 INT4 P76 INT3 P75 INT2 P74
DVO
Input/Output IO I I IO I I IO I I IO I I IO I I IO I I IO I IO I IO I IO O IO I O IO I O IO I O O IO I O O IO I O O IO I O O IO I O PORT45 Analog input 5 Key-on wake-up input 5 PORT44 Analog input 4 Key-on wake-up input 4 PORT43 Analog input 3 Key-on wake-up input 3 PORT42 Analog input 2 Key-on wake-up input 2 PORT41 Analog input 1 Key-on wake-up input 1 PORT40 Analog input 0 Key-on wake-up input 0 PORT77 External interrupt 4 input PORT76 External interrupt 3 input PORT75 External interrupt 2 input PORT74 Divider output PORT73 TCA1 input PPGA1 output PORT72 TCA0 input PPGA0 output PORT71 TC01 input PPG01 output PWM01 output PORT70 TC00 input PPG00 output PWM00 output PORT81 TC03 input PPG03 output PWM03 output PORT80 TC02 input PPG02 output PWM02 output PORT91 UART data input 1 UART data output 1
Functions
P73 TCA1
PPGA1
P72 TCA0
PPGA0
P71 TC01
PPG01 PWM01
P70 TC00
PPG00 PWM00
P81 TC03
PPG03 PWM03
P80 TC02
PPG02 PWM02
P91 RXD1 TXD1
RA000
Page 6
TMP89FM42
Table 1-1 Pin Names and Functions(3/3)
Pin Name P90 TXD1 RXD1 PB7 PB6 SCLK0 PB5 RXD0 TXD0 SI0 PB4 TXD0 RXD0 SO0 MODE Input/Output IO O I IO IO IO IO I O I IO O I O I PORT90 UART data output 1 UART data input 1 PORTB7 PORTB6 Serial clock input/output 0 PORTB5 UART data input 0 UART data output 0 Serial data input 0 PORTB4 UART data output 0 UART data input 0 Serial data output 0 Test pin for out-going test (fix to Low level). Analog reference voltage input pin for A/D conversion. / Analog power supply pin. VDD pin GND pin Functions
VAREF / AVDD
I
VDD VSS
I I
RA000
Page 7
1.4 Pin Names and Functions
TMP89FM42
RA000
Page 8
TMP89FM42
2. CPU Core
2.1 Configuration
The CPU core consists of a CPU, a system clock controller and a reset circuit. This chapter describes the CPU core address space, the system clock controller and the reset circuit.
2.2 Memory space
The 870/C1 CPU memory space consists of a code area to be accessed as instruction operation codes and operands and a data area to be accessed as sources and destinations of transfer and calculation instructions. Both the code and data areas have independent 64-Kbyte address spaces.
2.2.1
Code area
The code area stores operation codes, operands, vector tables for vector call instructions and interrupt vector tables. The RAM, the BOOTROM and the Flash are mapped in the code area.
0x0000 0x003F 0x0040 0x083F SWI instruction (0xFF) is fetched. 0x1000 0x17FF 0x1800
SWI instruction (0xFF) is fetched. RAM (2048 bytes)
SWI instruction (0xFF) is fetched. RAM (2048 bytes)
SWI instruction (0xFF) is fetched.
SWI instruction (0xFF) is fetched.
SWI instruction (0xFF) is fetched.
BOOTROM (2048 bytes)
BOOTROM (2048 bytes)
0x7FFF 0x8000
Flash (32768 bytes)
Flash (32768 bytes)
Flash (32768 bytes)
Flash (32768 bytes)
0xFFA0
0xFFBF
Vector table for vector call instructions (32 bytes)
Vector table for vector call instructions (32 bytes)
Vector table for vector call instructions (32 bytes)
Vector table for vector call instructions (32 bytes)
0xFFCC
0xFFFF
Interrupt vector table (52 bytes) Immediately after reset release
Interrupt vector table (52 bytes) When the RAM is mapped in the code area
Interrupt vector table (52 bytes) When the BOOTROM is mapped in the code area
Interrupt vector table (52 bytes) When the RAM and the BOOTROM are mapped in the code area
Note: Only the first 2 Kbytes of the BOOTROM are mapped in the memory map, except in the serial PROM mode.
Figure 2-1 Memory Map in the Code Area
RA001
Page 9
2. CPU Core
2.2 Memory space TMP89FM42
2.2.1.1
RAM
The RAM is mapped in the data area immediately after reset release. By setting SYSCR3 to "1" and writing 0xD4 to SYSCR4, RAM can be mapped to 0x0040to 0x083F in the code area to execute the program. At this time, by setting SYSCR to "1" and writing 0xD4 to SYSCR4, vector table for vector call instructions and interrupt except reset can be mapped to RAM. In the serial PROM mode, the RAM is mapped to 0x0040 to 0x083F in the code area, regardless of the value of SYSCR3. The program can be executed on the RAM using the RAM loader function.
Note 1: When the RAM is not mapped in the code area, the SWI instruction is fetched from 0x0040 to 0x083F. Note2: The contents of the RAM become unstable when the power is turned on and immediately after a reset is released. To execute the program by using the RAM, transfer the program to be executed in the initialization routine.
System control register 3
SYSCR3 (0x0FDE) 7 Bit Symbol Read/Write After reset R 0 6 R 0 5 R 0 4 R 0 3 R 0 2 RVCTR R/W 0 1 RAREA R/W 0 0 (RSTDIS) R/W 0
RAREA
Specifies mapping of the RAM in the code area
0: 1:
The RAM is not mapped from 0x0040 to 0x083F in the code area. The RAM is mapped from 0x0040 to 0x083F in the code area. Vector table for vector call instructions Vector table for interrupt 0xFFC8 to 0xFFFF in the code area 0x01C8 to 0x01FD in the code area
RVCTR
Specifies mapping of the vector table for vector call instructions and interrupts
0:
0xFFA0 to 0xFFBF in the code area 0x01A0 to 0x01BF in the code area
1:
Note 1: The value of SYSCR3 is invalid until 0xD4 is written into SYSCR4. Note 2: To assign vector address areas to RAM, set SYSCR3 to "1" and SYSCR3 to "1". Note 3: Do not set SYSCR3 to "0" by using the RAM loader program. If an interrupt occurs with SYSCR3 set to "0", the BOOTROM area is referenced as a vector address and, therefore, the program will not function properly. Note 4: Bits 7 to 3 of SYSCR3 are read as "0".
System control register 4
SYSCR4 (0x0FDF) 7 Bit Symbol Read/Write After reset 0 0 0 0 6 5 4 SYSCR4 W 0 0 0 0 3 2 1 0
SYSCR4
Writes the SYSCR3 data control code.
0xB2 : 0xD4 : 0x71 :
Enables the contents of SYSCR3. Enables the contents of SYSCR3 and SYSCR3 . Enables the contents of IRSTSR Others : Invalid
Note 1: SYSCR4 is a write-only register, and must not be accessed by using a read-modify-write instruction, such as a bit operation. Note 2: After SYSCR3 is modified, SYSCR4 should be written 0xB2 (Enable code for SYSCR3) in NORMAL mode when fcgck is fc/4 (CGCR=00). Otherwise, SYSCR3 may be enabled at unexpected timing. Note 3: After IRSTSR is modified, SYSCR4 should be written 0x71 (Enable code for IRSTSR in NORMAL mode when fcgck is fc/4 (CGCR=00). Otherwise, IRSTSR may be enabled at unexpected timing.
RA001
Page 10
TMP89FM42
System control status register 4
SYSSR4 (0x0FDF) 7 Bit Symbol Read/Write After reset R 0 6 R 0 5 R 0 4 R 0 3 R 0 2 RVCTRS R 0 1 RAREAS R 0 0 (RSTDIS) R 0
RAREAS
Status of mapping of the RAM in the code area Status of mapping of the vector address in the area
0: 1: 0: 1:
The enabled SYSCR3 data is "0". The enabled SYSCR3 data is "1". The enabled SYSCR3 data is "0". The enabled SYSCR3 data is "1".
RVCTRS
Note: Bits 7 to 3 of SYSSR4 are read as "0". Example: Program transfer (Transfer the program saved in the data area to the RAM.)
LD LD LD TRANS_RAM: LD LD INC INC DEC JRS HL, TRANSFER_START_ADDRESS DE, PROGRAM_START_ADDRESS BC, BYTE_OF_PROGRAM A, (DE) (HL), A HL DE BC F, TRANS_RAM ; Destination RAM address ; Source ROM address ; Number of bytes of the program to be executed -1 ; Reading the program to be transferred ; Writing the program to be transferred ; Destination address increment ; Source address increment ; Have all the programs been transferred?
2.2.1.2
BOOTROM
The BOOTROM is not mapped in the code area or the data area after reset release. Setting FLSMD to "1" maps the BOOTROM to 0x1000 to 0x17FF in the code area and to 0x1000 to 0x17FF in the data area. The BOOTROM can be easily written into the Flash by using the Application Programming Interface (API) integrated in the BOOTROM.
Note 1: When the BOOTROM is not mapped in the code area, an instruction is fetched from the Flash or an SWI instruction is fetched, depending on the capacity of the internal Flash. Note 2: Only the first 2 Kbytes of the BOOTROM are mapped in the memory map, except in the serial PROM mode.
Flash memory control register 1
FLSCR1 (0x0FD0) 7 Bit Symbol Read/Write After reset 0 6 (FLSMD) R/W 1 0 5 4 BAREA R/W 0 0 3 (FAREA) R/W 0 0 2 1 (ROMSEL) R/W 0 0
BAREA
Specifies mapping of the BOOTROM in the code and data areas
0: 1:
The BOOTROM is not mapped to 0x1000 to 0x17FF in the code area and to 0x1000 to 0x17FF in the data area. The BOOTROM is mapped to 0x1000 to 0x17FF in the code area and to 0x1000 to 0x17FF in the data area.
Note: The flash memory control register 1 has a double-buffer structure comprised of the register FLSCR1 and a shift register. Writing "0xD5" to the register FLSCR2 allows a register setting to be reflected and take effect in the shift register. This means that a register setting value does not take effect until "0xD5" is written to the register FLSCR2. The value of the shift register can be checked by reading the register FLSCRM.
RA001
Page 11
2. CPU Core
2.2 Memory space TMP89FM42
Flash memory control register 2
FLSCR2 (0x0FD1) Bit Symbol Read/Write After reset * * * * 7 6 5 4 CR1EN W * * * * 3 2 1 0
CR1EN
FLSCR1 register enable/disable control
0xD5 Others
Enable a change in the FLSCR1 setting Reserved
2.2.1.3
Flash
The Flash is mapped to 0x8000 to 0xFFFF in the code area after reset release.
2.2.2
Data area
The data area stores the data to be accessed as sources and destinations of transfer and calculation instructions. The SFR, the RAM, the BOOTROM and the FLASH are mapped in the data area.
0x0000 0x003F 0x0040 0x083F
SFR1 (64 bytes) RAM (2048 bytes) 0xFF is read
SFR1 (64 bytes) RAM (2048 bytes) 0xFF is read SFR3 (192 bytes) SFR2 (256 bytes) BOOTROM (2048 bytes)
0x0E40 0x0EFF 0x0F00 0x0FFF 0x1000 0x17FF 0x1800
SFR3 (192 bytes) SFR2 (256 bytes)
0xFF is read 0x7FFF 0x8000
0xFF is read
Flash (32768 bytes)
Flash (32768 bytes)
0xFFFF Immediately after reset release When the BOOTROM is mapped in the data area
Note: Only the first 2 Kbytes of the BOOTROM are mapped in the memory map, except in the serial PROM mode.
Figure 2-2 Memory Map in the Data Area
RA001
Page 12
TMP89FM42
2.2.2.1
SFR
The SFR is mapped to 0x0000 to 0x003F (SFR1), 0x0F00 to 0x0FFF (SFR2) and 0x0E40 to 0x0EFF (SFR3) in the data area after reset release.
Note: Don't access the reserved SFR.
2.2.2.2
RAM
The RAM is mapped to 0x0040 to 0x083F in the data area after reset release.
Note: The contents of the RAM become unstable when the power is turned on and immediately after a reset is released. To execute the program by using the RAM, transfer the program to be executed in the initialization routine. Example: RAM initialization program
LD LD LD HL, RAM_TOP_ADDRESS A, 0x00 BC, BYTE_OF_CLEAR_BYTES (HL), A HL BC F, CLR_RAM ; Head of address of the RAM to be initialized ; Initialization data ; Number of bytes of RAM to be initialized -1 ; Initialization of the RAM ; Initialization address increment ; Have all the RAMs been initialized?
CLR_RAM:
LD INC DEC JRS
2.2.2.3
BOOTROM
The BOOTROM is not mapped in the code area or the data area after reset release. Setting FLSMD to "1" maps the BOOTROM to 0x1000 to 0x17FF in the code area and to 0x1000 to 0x17FF in the data area. The BOOTROM can be easily written into the Flash by using the Application Programming Interface (API) integrated in the BOOTROM.
Note 1: When the BOOTROM is not mapped in the data area, 0xFF is read from 0x1000 to 0x17FF. Note2: Only the first 2 Kbytes of the BOOTROM are mapped in the memory map, except in the serial PROM mode.
Flash memory control register 1
FLSCR1 (0x0FD0) 7 Bit Symbol Read/Write After reset 0 6 (FLSMD) R/W 1 0 5 4 BAREA R/W 0 0 3 (FAREA) R/W 0 0 2 1 (ROMSEL) R/W 0 0
BAREA
Specifies mapping of the BOOTROM in the code and data areas
0: 1:
The BOOTROM is not mapped to 0x1000 to 0x17FF in the code area and to 0x1000 to 0x17FF in the data area. The BOOTROM is mapped to 0x1000 to 0x17FF in the code area and to 0x1000 to 0x17FF in the data area.
Note: The flash memory control register 1 has a double-buffer structure comprised of the register FLSCR1 and a shift register. Writing "0xD5" to the register FLSCR2 allows a register setting to be reflected and take effect in the shift register. This means that a register setting value does not take effect until "0xD5" is written to the register FLSCR2. The value of the shift register can be checked by reading the register FLSCRM.
Flash memory control register 2
FLSCR2 (0x0FD1) Bit Symbol Read/Write After reset * * * * 7 6 5 4 CR1EN W * * * * 3 2 1 0
RA001
Page 13
2. CPU Core
2.2 Memory space TMP89FM42
CR1EN
FLSCR1 register enable/disable control
0xD5 Others
Enable a change in the FLSCR1 setting Reserved
2.2.2.4
Flash
The Flash is mapped to 0x8000 to 0xFFFF in the data area after reset release.
RA001
Page 14
TMP89FM42
2.3 System clock controller
2.3.1 Configuration
The system clock controller consists of a clock generator, a clock gear, a timing generator, a warm-up counter and an operation mode control circuit.
WUCCR WUCDR
Warm-up counter INTWUC interrupt XEN/XTEN STOP Clock generator XIN TBTCR DV9CK SYSCR1 SYSCR2
High-frequency clock oscillation circuit
XOUT
fc
Clock gear (x1/4,x1/2,x1) FCGCKSEL Clock gear control register
fcgck Timing generator Operation mode control circuit
System control register System clock 1/4
XTIN Low-frequency clock oscillation circuit XTOUT fs
Oscillation/stop control
Figure 2-3 System Clock Controller
2.3.2
Control
The system clock controller is controlled by system control register 1 (SYSCR1), system control register 2 (SYSCR2), the warm-up counter control register (WUCCR), the warm-up counter data register (WUCDR) and the clock gear control register (CGCR).
System control register 1
SYSCR1 (0x0FDC) 7 Bit Symbol Read/Write After reset STOP R/W 0 6 RELM R/W 0 5 OUTEN R/W 0 4 DV9CK R/W 0 3 R 1 2 R 0 1 R 0 0 R 0
STOP
Activates the STOP mode
0: 1: 0:
Operate the CPU and the peripheral circuits Stop the CPU and the peripheral circuits (activate the STOP mode) Edge-sensitive release mode (Release the STOP mode at the rising edge of the STOP mode release signal) Level-sensitive release mode (Release the STOP mode at the "H" level of the STOP mode release signal) High impedance Output hold fcgck/29 fs/4
RELM
Selects the STOP mode release method
1:
OUTEN
Selects the port output state in the STOP mode Selects the input clock to stage 9 of the divider
0: 1: 0: 1:
DV9CK
Note 1: fcgck: Gear clock [Hz], fs: Low-frequency clock [Hz] Note 2: Bits 2, 1 and 0 of SYSCR1 are read as "0". Bit 3 is read as "1".
RA001
Page 15
2. CPU Core
2.3 System clock controller TMP89FM42
Note 3: If the STOP mode is activated with SYSCR1 set at "0", the port internal input is fixed to "0". Therefore, an external interrupt may be set at the falling edge, depending on the pin state when the STOP mode is activated. Note 4: The P11 pin is also used as the STOP pin. When the STOP mode is activated, the pin reverts to high impedance state and is put in input mode, regardless of the state of SYSCR1. Note 5: Writing of the second byte data will be executed improperly if the operation is switched to the STOP state by an instruction, such as LDW, which executes 2-byte data transfer at a time. Note 6: Don't set SYSCK1 to "1" before the oscillation of the low-frequency clock oscillation circuit becomes stable. Note 7: In the SLOW1/2 or SLEEP1 mode, fs/4 is input to stage 9 of the divider, regardless of the state of SYSCR1< DV9CK >.
System control register 2
SYSCR2 (0x0FDD) 7 Bit Symbol Read/Write After reset R 0 6 XEN R/W 1 5 XTEN R/W 0 4 SYSCK R/W 0 3 IDLE R/W 0 2 TGHALT R/W 0 1 R 0 0 R 0
XEN
Controls the high-frequency clock oscillation circuit Controls the low-frequency clock oscillation circuit Selects a system clock CPU and WDT control (IDLE1/2 or SLEEP1 mode) TG control (IDLE0 or SLEEP0 mode)
0: 1: 0: 1: 0: 1: 0: 1: 0: 1:
Stop oscillation Continue or start oscillation Stop oscillation Continue or start oscillation Gear clock (fcgck) (NORMAL1/2 or IDLE1/2 mode) Low-frequency clock (fs/4) (SLOW1/2 or SLEEP1 mode) Operate the CPU and the WDT Stop the CPU and the WDT (Activate IDLE1/2 or SLEEP1 mode) Enable the clock supply from the TG to all the peripheral circuits Disable the clock supply from the TG to the peripheral circuits except the TBT (Activate IDLE0 or SLEEP0 mode)
XTEN
SYSCK
IDLE
TGHALT
Note 1: fcgck: Gear clock [Hz], fs: Low-frequency clock [Hz] Note 2: WDT: Watchdog timer, TG: Timing generator Note 3: Don't set both SYSCR2 and SYSCR2 to "1" simultaneously. Note 4: Writing of the second byte data will be executed improperly if the operation is switched to the IDLE state by an instruction, such as LDW, which executes 2-byte data transfer at a time. Note 5: When the IDLE1/2 or SLEEP1 mode is released, SYSCR2 is cleared to "0" automatically. Note 6: When the IDLE0 or SLEEP0 mode is released, SYSCR2 is cleared to "0" automatically. Note 7: Bits 7, 1 and 0 of SYSCR2 are read as "0".
Warm-up counter control register
WUCCR (0x0FCD) 7 Bit Symbol Read/Write After reset WUCRST W 0 6 R 0 5 R 0 4 R 0 1 3 WUCDIV R/W 1 2 1 WUCSEL R/W 0 0 R 1
WUCRST
Resets and stops the warm-up counter
0: 1: 00 : 01 : 10 : 11 : 0: 1:
Clear and stop the counter Source clock Source clock / 2 Source clock / 22 Source clock / 23 Select the high-frequency clock (fc) Select the low-frequency clock (fs)
WUCDIV
Selects the frequency division of the warm-up counter source clock
WUCSEL
Selects the warm-up counter source clock
Note 1: fc: High-frequency clock [Hz], fs: Low-frequency clock [Hz] Note 2: WUCCR is cleared to "0" automatically, and need not be cleared to "0" after being set to "1". Note 3: Bits 7 to 4 of WUCCR are read as "0". Bit 0 is read as "1". Note 4: Before starting the warm-up counter operation, set the source clock and the frequency division rate at WUCCR and set the warm-up time at WUCDR.
RA001
Page 16
TMP89FM42
Warm-up counter data register
WUCDR (0x0FCE) 7 Bit Symbol Read/Write After reset 0 1 1 0 6 5 4 WUCDR R/W 0 1 1 0 3 2 1 0
WUCDR
Warm-up time setting
Note 1: Don't start the warm-up counter operation with WUCDR set at "0x00".
Clock gear control register
CGCR (0x0FCF) 7 Bit Symbol Read/Write After reset R 0 6 R 0 5 R 0 4 R 0 3 R 0 2 R 0 0 1 FCGCKSEL R/W 0 0
FCGCKSEL
Clock gear setting
00 : 01 : 10 : 11 :
fcgck = fc / 4 fcgck = fc / 2 fcgck = fc Reserved
Note 1: fcgck: Gear clock [Hz], fc: High-frequency clock [Hz] Note 2: Don't change CGCR in the SLOW mode. Note 3: Bits 7 to 2 of CGCR are read as "0".
2.3.3
Functions
Clock generator
The clock generator generates the basic clock for the system clocks to be supplied to the CPU core and peripheral circuits. It contains two oscillation circuits: one for the high-frequency clock and the other for the low-frequency clock. The oscillation circuit pins are also used as ports P0. For the setting to use them as ports, refer to the chapter of I/O Ports. To use ports P00 and P01 as the high-frequency clock oscillation circuits (the XIN and XOUT pins), set P0FC0 to "1" and then set SYSCR2 to "1". To use ports P02 and P03 as the low-frequency clock oscillation circuits (the XTIN and XTOUT pins), set P0FC2 to "1" and then set SYSCR2 to "1". The high-frequency (fc) clock and the low-frequency (fs) clock can easily be obtained by connecting an oscillator between the XIN and XOUT pins and between the XTIN and XTOUT pins respectively. Clock input from an external oscillator is also possible. In this case, external clocks are applied to the XIN/XTIN pins and the XOUT/XTOUT pins are kept open. Enabling/disabling the oscillation of the high-frequency clock oscillation circuit and the low-frequency clock oscillation circuit and switching the pin function to ports are controlled by the software and hardware. The software control is executed by SYSCR2, SYSCR2 and the P0 port function control register P0FC.
2.3.3.1
RA001
Page 17
2. CPU Core
2.3 System clock controller TMP89FM42
The hardware control is executed by reset release and the operation mode control circuit when the operation is switched to the STOP mode as described in "2.3.5 Operation mode control circuit".
Note: No hardware function is available for external direct monitoring of the basic clock. The oscillation frequency can be adjusted by programming the system to output pulses at a certain frequency to a port (for example, a clock output) with interrupts disabled and the watchdog timer disabled and monitoring the output. An adjustment program must be created in advance for a system that requires adjustment of the oscillation frequency.
To prevent the dead lock of the CPU core due to the software-controlled enabling/disabling of the oscillation, an internal factor reset is generated depending on the combination of values of the clock selected as the main system clock, SYSCR2, SYSCR2 and the P0 port function control register P0FC0. Table 2-1 Prohibited Combinations of Oscillation Enable Register Conditions
P0FC0 Don't Care SYSCR2 0 SYSCR2 0 SYSCR2 Don't Care State All the oscillation circuits are stopped. The low-frequency clock (fs) is selected as the main system clock, but the low-frequency clock oscillation circuit is stopped. The high-frequency clock (fc) is selected as the main system clock, but the high-frequency clock oscillation circuit is stopped. The high-frequency clock oscillation circuit is allowed to oscillate, but the port is set as a general-purpose port.
Don't Care
Don't Care
0
1
Don't Care
0
Don't Care
0
0
1
Don't Care
Don't Care
Note: It takes a certain period of time after SYSCR2 is changed before the main system clock is switched. If the currently operating oscillation circuit is stopped before the main system clock is switched, the internal condition becomes as shown in Table 2-1 and a system clock reset occurs. For details of clock switching, refer to "2.3.6 Operation Mode Control".
High-frequency clock XIN XOUT XIN XOUT XTIN
Low-frequency clock XTOUT XTIN XTOUT
(Open)
(Open)
(a) Crystal or ceramic oscillator
(b) External oscillator
(c) Crystal oscillator
(d) External oscillator
Figure 2-4 Examples of Oscillator Connection
2.3.3.2
Clock gear
The clock gear is a circuit that selects a gear clock (fcgck) obtained by dividing the high-frequency clock (fc) and inputs it to the timing generator. Selects a divided clock at CGCR. Two machine cycles are needed after CGCR is changed before the gear clock (fcgck) is changed. The gear clock (fcgck) may be longer than the set clock width, immediately after CGCR is changed.
RA001
Page 18
TMP89FM42
Immediately after reset release, the gear clock (fcgck) becomes the clock that is a quarter of the highfrequency clock (fc). Table 2-2 Gear Clock (fcgck)
CGCR 00 01 10 11 fcgck fc / 4 fc / 2 fc Reserved
Note: Don't change CGCR in the SLOW mode. This may stop the gear clock (fcgck) from being changed.
2.3.3.3
Timing generator
The timing generator is a circuit that generates system clocks to be supplied to the CPU core and the peripheral circuits, from the gear clock (fcgck) or the clock that is a quarter of the low-frequency clock (fs). The timing generator has the following functions: 1. Generation of the main system clock (fm) 2. Generation of clocks for the timer counter, the time base timer and other peripheral circuits
Main system clock fm
Main system clock generator
Machine cycle counter
SYSCR2 SYSCR1 Prescaler Gear clock fcgck Divider A B Multiplexer A quarter of the basic clock for the low-frequency clock S Divider Y
Timer counter, time base timer and other peripheral circuits
Figure 2-5 Configuration of Timing Generator
(1)
Configuration of timing generator The timing generator consists of a main system clock generator, a prescaler, a 21-stage divider and a machine cycle counter. 1. Main system clock generator This circuit selects the gear clock (fcgck) or the clock that is a quarter of the low-frequency clock (fs) for the main system clock (fm) to operate the CPU core. Clearing SYSCR2 to "0" selects the gear clock (fcgck). Setting it to "1" selects the clock that is a quarter of the low-frequency clock (fs). It takes a certain period of time after SYSCR2 is changed before the main system clock is switched. If the currently operating oscillation circuit is stopped before the main system clock is switched, the internal condition becomes as shown in Table 2-1 and a system clock reset occurs. For details of clock switching, refer to "2.3.6 Operation Mode Control".
RA001
Page 19
2. CPU Core
2.3 System clock controller TMP89FM42
2. Prescaler and divider These circuits divide fcgck. The divided clocks are supplied to the timer counter, the time base timer and other peripheral circuits. When both SYSCR1 and SYSCR2 are "0", the input clock to stage 9 of the divider becomes the output of stage 8 of the divider. When SYSCR1 or SYSCR2 is "1", the input clock to stage 9 of the divider becomes fs/4. When SYSCR2 is "1", the outputs of stages 1 to 8 of the divider and prescaler are stopped. The prescaler and divider are cleared to "0" at a reset and at the end of the warm-up operation that follows the release of STOP mode. 3. Machine cycle Instruction execution is synchronized with the main system clock (fm). The minimum instruction execution unit is called a "machine cycle". One machine cycle corresponds to one main system clock. There are a total of 11 different types of instructions for the TLCS-870/C1 Series: 10 types ranging from 1-cycle instructions, which require one machine cycle for execution, to 10cycle instructions, which require 10 machine cycles for execution, and 13-cycle instructions, which require 13 machine cycles for execution.
2.3.4
Warm-up counter
The warm-up counter is a circuit that counts the high-frequency clock (fc) and the low-frequency clock (fs), and it consists of a source clock selection circuit, a 3-stage frequency division circuit and a 14-stage counter. The warm-up counter is used to secure the time after a power-on reset is released before the supply voltage becomes stable and secure the time after the STOP mode is released or the operation mode is changed before the oscillation by the oscillation circuit becomes stable.
WUCCR WUCSEL WUCDIV WUCRST
SYSCR2 XEN XTEN STOP
SYSCR1
INTWUC interrupt
Warm-up counter controller
S
Clock for high-frequency clock oscillation circuit (fc) Clock for low-frequency clock oscillation circuit (fs) Enable/disable counting up
Enable CPU operation
AZ B
123
S D CZ B A
1 2 3 4 5 6 7 8 9 10 11 12 13 14
Comparator
01234567
WUCDR
Figure 2-6 Warm-up Counter Circuit
RA001
Page 20
TMP89FM42
2.3.4.1
Warm-up counter operation when the oscillation is enabled by the hardware
(1) When a power-on reset is released or a reset is released The warm-up counter serves to secure the time after a power-on reset is released before the supply voltage becomes stable and the time after a reset is released before the oscillation by the high-frequency clock oscillation circuit becomes stable. When the power is turned on and the supply voltage exceeds the power-on reset release voltage, the warm-up counter reset signal is released. At this time, the CPU and the peripheral circuits are held in the reset state. A reset signal initializes WUCCR to "0" and WUCCR to "11", which selects the high-frequency clock (fc) as the input clock to the warm-up counter. When a reset is released for the warm-up counter, the high-frequency clock (fc) is input to the warm-up counter, and the 14-stage counter starts counting the high-frequency clock (fc). When the upper 8 bits of the warm-up counter become equal to WUCDR, counting is stopped and a reset is released for the CPU and the peripheral circuits. WUCDR is initialized to 0x66 after reset release, which makes the warm-up time 0x66 x 29/fc[s].
Note: The clock output from the oscillation circuit is used as the input clock to the warm-up counter. The warm-up time contains errors because the oscillation frequency is unstable until the oscillation circuit becomes stable.
(2)
When the STOP mode is released The warm-up counter serves to secure the time after the oscillation is enabled by the hardware before the oscillation becomes stable at the release of the STOP mode. The high-frequency clock (fc) or the low-frequency clock (fs), which generates the main system clock when the STOP mode is activated, is selected as the input clock for frequency division circuit, regardless of WUCCR. Before the STOP mode is activated, select the division rate of the input clock to the warm-up counter at WUCCR and set the warm-up time at WUCDR. When the STOP mode is released, the 14-stage counter starts counting the input clock selected in the frequency division circuit. When the upper 8 bits of the warm-up counter become equal to WUCDR, counting is stopped and the operation is restarted by an instruction that follows the STOP mode activation instruction.
Clock that generates the main system clock when the STOP mode is activated
WUCCR
WUCCR
Counter input clock
Warm-up time
00 01 fc Don't Care 10 11 00 01 fs Don't Care 10 11
fc fc / 2 fc / 22 fc / 23
26 / fc to 255 x 26 / fc 27 / fc to 255 x 27 / fc 28 / fc to 255 x 28 / fc 29 / fc to 255 x 29 / fc 26 / fs to 255 x 26 / fs 27 / fs to 255 x 27 / fs 28 / fs to 255 x 28 / fs 29 / fs to 255 x 29 / fs
fs fs / 2 fs / 22 fs / 23
Note 1: When the operation is switched to the STOP mode during the warm-up for the oscillation enabled by the software, the warm-up counter holds the value at the time, and restarts counting after the STOP mode is released. In this case, the warm-up time at the release of the STOP mode becomes insufficient. Don't switch the operation to the STOP mode during the warm-up for the oscillation enabled by the software.
RA001
Page 21
2. CPU Core
2.3 System clock controller TMP89FM42
Note 2: The clock output from the oscillation circuit is used as the input clock to the warm-up counter. The warm-up time contains errors because the oscillation frequency is unstable until the oscillation circuit becomes stable. Set the sufficient time for the oscillation start property of the oscillator.
2.3.4.2
Warm-up counter operation when the oscillation is enabled by the software
The warm-up counter serves to secure the time after the oscillation is enabled by the software before the oscillation becomes stable, at a mode change from NORMAL1 to NORMAL2 or from SLOW1 to SLOW2. Select the input clock to the frequency division circuit at WUCCR. Select the input clock to the 14-stage counter at WUCCR. After the warm-up time is set at WUCDR, setting SYSCR2 or SYSCR2 to "1" allows the stopped oscillation circuit to start oscillation and the 14-stage counter to start counting the selected input clock. When the upper 8 bits of the counter become equal to WUCDR, an INTWUC interrupt occurs, counting is stopped and the counter is cleared. Set WUCCR to "1" to discontinue the warm-up operation. By setting it to "1", the count-up operation is stopped, the warm-up counter is cleared, and WUCCR is cleared to "0". SYSCR2 and SYSCR2 hold the values when WUCCR is set to "1". To restart the warm-up operation, SYSCR2 or SYSCR2 must be cleared to "0".
Note: The warm-up counter starts counting when SYSCR2 or SYSCR2 is changed from "0" to "1". The counter will not start counting by writing "1" to SYSCR2 or SYSCR2 when it is in the state of "1".
WUCCR
WUCCR 00 01
Counter input clock fc fc / 2 fc / 22 fc / 23 fs fs / 2 fs / 22 fs / 23 26
Warm-up time / fc to 255 x 26 / fc
27 / fc to 255 x 27 / fc 28 / fc to 255 x 28 / fc 29 / fc to 255 x 29 / fc 26 / fs to 255 x 26 / fs 27 / fs to 255 x 27 / fs 28 / fs to 255 x 28 / fs 29 / fs to 255 x 29 / fs
0 10 11 00 01 1 10 11
Note: The clock output from the oscillation circuit is used as the input clock to the warm-up counter. The warm-up time contains errors because the oscillation frequency is unstable until the oscillation circuit becomes stable. Set the sufficient time for the oscillation start property of the oscillator.
2.3.5
Operation mode control circuit
The operation mode control circuit starts and stops the oscillation circuits for the high-frequency and lowfrequency clocks, and switches the main system clock (fm). There are three operating modes: the single-clock mode, the dual-clock mode and the STOP mode. These modes are controlled by the system control registers (SYSCR1 and SYSCR2). Figure 2-7 shows the operating mode transition diagram.
2.3.5.1
Single-clock mode
Only the gear clock (fcgck) is used for the operation in the single-clock mode.
RA001
Page 22
TMP89FM42
The main system clock (fm) is generated from the gear clock (fcgck). Therefore, the machine cycle time is 1/fcgck [s]. The gear clock (fcgck) is generated from the high-frequency clock (fc). In the single-clock mode, the low-frequency clock generation circuit pins P03 (XTIN) and P04 (XTOUT) can be used as the I/O ports.
(1)
NORMAL1 mode In this mode, the CPU core and the peripheral circuits operate using the gear clock (fcgck). The NORMAL1 mode becomes active after reset release.
(2)
IDLE1 mode In this mode, the CPU and the watchdog timer stop and the peripheral circuits operate using the gear clock (fcgck). The IDLE1 mode is activated by setting SYSCR2 to "1" in the NORMAL1 mode. When the IDLE1 mode is activated, the CPU and the watchdog timer stop. When the interrupt latch enabled by the interrupt enable register EFR becomes "1", the IDLE1 mode is released to the NORMAL1 mode. When the IMF (interrupt master enable flag) is "1" (interrupts enabled), the operation returns normal after the interrupt processing is completed. When the IMF is "0" (interrupts disabled), the operation is restarted by the instruction that follows the IDLE1 mode activation instruction.
(3)
IDLE0 mode In this mode, the CPU and the peripheral circuits stop, except the oscillation circuits and the time base timer. In the IDLE0 mode, the peripheral circuits stop in the states when the IDLE0 mode is activated or become the same as the states when a reset is released. For operations of the peripheral circuits in the IDLE0 mode, refer to the section of each peripheral circuit. The IDLE0 mode is activated by setting SYSCR2 to "1" in the NORMAL1 mode. When the IDLE0 mode is activated, the CPU stops and the timing generator stops the clock supply to the peripheral circuits except the time base timer. When the falling edge of the source clock selected at TBTCR is detected, the IDLE0 mode is released, the timing generator starts the clock supply to all the peripheral circuits and the NORMAL1 mode is restored. Note that the IDLE0 mode is activated and restarted, regardless of the setting of TBTCR. When the IDLE0 mode is activated with TBTCR set at "1", the INTTBT interrupt latch is set after the NORMAL mode is restored. When the IMF is "1" and the EF5 (the individual interrupt enable flag for the time base timer) is "1", the operation returns normal after the interrupt processing is completed. When the IMF is "0" or when the IMF is "1" and the EF5 (the individual interrupt enable flag for the time base timer) is "0", the operation is restarted by the instruction that follows the IDLE0 mode activation instruction.
RA001
Page 23
2. CPU Core
2.3 System clock controller TMP89FM42
2.3.5.2
Dual-clock mode
The gear clock (fcgck) and the low-frequency clock (fs) are used for the operation in the dual-clock mode. The main system clock (fm) is generated from the gear clock (fcgck) in the NORMAL2 or IDLE2 mode, and generated from the clock that is a quarter of the low-frequency clock (fs) in the SLOW1/2 or SLEEP0/1 mode. Therefore, the machine cycle time is 1/fcgck [s] in the NORMAL2 or IDLE2 mode and is 4/fs [s] in the SLOW1/2 or SLEEP0/1 mode. P03 (XTIN) and P04 (XTOUT) are used as the low-frequency clock oscillation circuit pins. (These pins cannot be used as I/O ports in the dual-clock mode.) The operation of the TLCS-870/C1 Series becomes the single-clock mode after reset release. To operate it in the dual-clock mode, allow the low-frequency clock to oscillate at the beginning of the program.
(1)
NORMAL2 mode In this mode, the CPU core operates using the gear clock (fcgck), and the peripheral circuits operate using the gear clock (fcgck) or the clock that is a quarter of the low-frequency clock (fs).
(2)
SLOW2 mode In this mode, the CPU core and the peripheral circuits operate using the clock that is a quarter of the low-frequency clock (fs). In the SLOW mode, some peripheral circuits become the same as the states when a reset is released. For operations of the peripheral circuits in the SLOW mode, refer to the section of each peripheral circuit. Set SYSCR2 to switch the operation mode from NORMAL2 to SLOW2 or from SLOW2 to NORMAL2. In the SLOW2 mode, outputs of the prescaler and stages 1 to 8 of the divider stop.
(3)
SLOW1 mode In this mode, the high-frequency clock oscillation circuit stops operation and the CPU core and the peripheral circuits operate using the clock that is a quarter of the low-frequency clock (fs). This mode requires less power to operate the high-frequency clock oscillation circuit than in the SLOW2 mode. In the SLOW mode, some peripheral circuits become the same as the states when a reset is released. For operations of the peripheral circuits in the SLOW mode, refer to the section of each peripheral circuit. Set SYSCR2 to switch the operation between the SLOW1 and SLOW2 modes. In the SLOW1 or SLEEP1 mode, outputs of the prescaler and stages 1 to 8 of the divider stop.
(4)
IDLE2 mode In this mode, the CPU and the watchdog timer stop and the peripheral circuits operate using the gear clock (fcgck) or the clock that is a quarter of the low-frequency clock (fs). The IDLE2 mode can be activated and released in the same way as for the IDLE1 mode. The operation returns to the NORMAL2 mode after this mode is released.
RA001
Page 24
TMP89FM42
(5)
SLEEP1 mode In this mode, the high-frequency clock oscillation circuit stops operation, the CPU and the watchdog timer stop, and the peripheral circuits operate using the clock that is a quarter of the low-frequency clock (fs). In the SLEEP1 mode, some peripheral circuits become the same as the states when a reset is released. For operations of the peripheral circuits in the SLEEP1 mode, refer to the section of each peripheral circuit. The SLEEP1 mode can be activated and released in the same way as for the IDLE1 mode. The operation returns to the SLOW1 mode after this mode is released. In the SLOW1 or SLEEP1 mode, outputs of the prescaler and stages 1 to 8 of the divider stop.
(6)
SLEEP0 mode In this mode, the high-frequency clock oscillation circuit stops operation, the time base timer operates using the clock that is a quarter of the low-frequency clock (fs), and the core and the peripheral circuits stop. In the SLEEP0 mode, the peripheral circuits stop in the states when the SLEEP0 mode is activated or become the same as the states when a reset is released. For operations of the peripheral circuits in the SLEEP0 mode, refer to the section of each peripheral circuit. The SLEEP0 mode can be activated and released in the same way as for the IDLE0 mode. The operation returns to the SLOW1 mode after this mode is released. In the SLEEP0 mode, the CPU stops and the timing generator stops the clock supply to the peripheral circuits except the time base timer.
2.3.5.3
STOP mode
In this mode, all the operations in the system, including the oscillation circuits, are stopped and the internal states in effect before the system was stopped are held with low power consumption. In the STOP mode, the peripheral circuits stop in the states when the STOP mode is activated or become the same as the states when a reset is released. For operations of the peripheral circuits in the STOP mode, refer to the section of each peripheral circuit. The STOP mode is activated by setting SYSCR1 to "1". The STOP mode is released by the STOP mode release signals. After the warm-up time has elapsed, the operation returns to the mode that was active before the STOP mode, and the operation is restarted by the instruction that follows the STOP mode activation instruction.
RA001
Page 25
2. CPU Core
2.3 System clock controller TMP89FM42
2.3.5.4
Transition of operation modes
RESET Reset release IDLE0 mode
Warm-up that follows reset release
Warm-up completed SYSCR2 = "1" (Note 2) T SYSCR2 = "1" IDLE0 mode Interrupt (a) Single-clock mode SYSCR2 = "0" SYSCR2 = "1" NORMAL2 mode Interrupt SYSCR2 = "0" SYSCR2 = "1" STOP mode release signal STOP NORMAL1 mode STOP mode release signal SYSCR2 = "1" SYSCR1 = "1" SYSCR1 = "1"
IDLE2 mode
SLOW2 mode SYSCR2 = "1" SYSCR2 = "0" SYSCR2 = "1" SLEEP1 mode Interrupt (b) Dual-clock mode SLEEP0 mode SLOW1 mode STOP mode release (Note 2) SYSCR2 = "1" signal SYSCR1 = "1"
Note 1: The NORMAL1 and NORMAL2 modes are generically called the NORMAL mode; the SLOW1 and SLOW2 modes are called the SLOW mode; the IDLE0, IDLE1 and IDLE2 modes are called the IDLE mode; and the SLEEP0 and SLEEP1 are called the SLEEP mode. Note 2: The mode is released by the falling edge of the source clock selected at TBTCR.
Figure 2-7 Operation Mode Transition Diagram
RA001
Page 26
TMP89FM42
Table 2-3 Operation Modes and Conditions
Oscillation circuit Operation mode High-frequency Low-frequency CPU core Watchdog timer Time base timer Other peripheral circuits Machine cycle time
RESET NORMAL1 Oscillation Single clock IDLE1 IDLE0 STOP Stop Stop
Reset Operate
Reset Operate
Reset
Reset
Operate Operate Stop Stop Stop Stop Operate with the high frequency Operate with the high/low frequency Stop Operate with the low frequency Operate with the low frequency
1 / fcgck [s]
A|
NORMAL2
1 / fcgck [s]
IDLE2
Oscillation
Stop Operate with the low frequency Operate with the low frequency
SLOW2 Oscillation Dual clock SLOW1
Operate Operate
4/ fs [s]
SLEEP1 SLEEP0 STOP
Stop Stop Stop Stop Stop Stop A|
2.3.6
Operation Mode Control
STOP mode
The STOP mode is controlled by system control register 1 (SYSCR1) and the STOP mode release signals.
2.3.6.1
(1)
Start the STOP mode The STOP mode is started by setting SYSCR1 to "1". In the STOP mode, the following states are maintained: 1. Both the high-frequency and low-frequency clock oscillation circuits stop oscillation and all internal operations are stopped. 2. The data memory, the registers and the program status word are all held in the states in effect before STOP mode was started. The port output latch is determined by the value of SYSCR1. 3. The prescaler and the divider of the timing generator are cleared to "0". 4. The program counter holds the address of the instruction 2 ahead of the instruction (e.g., [SET (SYSCR1).7]) which started the STOP mode.
(2)
Release the STOP mode The STOP mode is released by the following STOP mode release signals. It is also released by a reset by the RESET pin, a power-on reset and a reset by the voltage detection circuits. When a reset is released, the warm-up starts. After the warm-up is completed, the NORMAL1 mode becomes active. 1. Release by the STOP pin
RA001
Page 27
2. CPU Core
2.3 System clock controller TMP89FM42
2. Release by key-on wakeup 3. Release by the voltage detection circuits
Note: During the STOP period (from the start of the STOP mode to the end of the warm-up), due to changes in the external interrupt pin signal, interrupt latches may be set to "1" and interrupts may be accepted immediately after the STOP mode is released. Before starting the STOP mode, therefore, disable interrupts. Also, before enabling interrupts after STOP mode is released, clear unnecessary interrupt latches.
1. Release by the STOP pin Release the STOP mode by using the STOP pin. To release the STOP mode by using the STOP pin, set VDCR2 to "00" or "10". (For details of VDCR2, refer to the section of voltage detection circuits.) The STOP mode release by the STOP pin includes the level-sensitive release mode and the edge-sensitive release mode, either of which can be selected at SYSCR1. The STOP pin is also used as the P11 port and the INT5 (external interrupt input 5) pin. - Level-sensitive release mode The STOP mode is released by setting the STOP pin high. Setting SYSCR1 to "1" selects the level-sensitive release mode. This mode is used for the capacitor backup when the main power supply is cut off and the long term battery backup. Even if an instruction for starting the STOP mode is executed while the STOP pin input is high, the STOP mode does not start. Thus, to start the STOP mode in the levelsensitive release mode, it is necessary for the program to first confirm that the STOP pin input is low. This can be confirmed by testing the port by the software or using interrupts
Note: When the STOP mode is released, the warm-up counter source clock automatically changes to the clock that generated the main system clock when the STOP mode was started, regardless of WUCCR.
Example: Starting the STOP mode from the SLOW mode with an INT5 interrupt (Warm-up time at release of the STOP mode is about 450ms at fs=32.768 KHz.)
PINT5: TEST JRS LD LD LD DI SET SINT5: RETI (SYSCR1).7 (P0PRD).5 F, SINT5 (SYSCR1), 0x40 (WUCCR), 0x03 (WUCDR),0xE8 ; To reject noise, the STOP mode does not start ; if the STOP pin input is high. ; Sets up the level-sensitive release mode ; WUCCR = 00 (No division) (Note) ; Sets the warm-up time ; 450 ms/1.953 ms = 230.4 round up to 0xE8 ; IMF = 0 ; Starts the STOP mode
Note: When the STOP mode is released, the warm-up counter source clock automatically changes to the clock that generated the main system clock when the STOP mode was started, regardless of WUCCR.
STOP pin
VIH
XOUT pin NORMAL mode STOP mode Confirm by program that the STOP pin input is low and start the STOP mode. Warm-up NORMAL mode
The STOP mode is released by the hardware. Always released if the STOP pin input is high.
RA001
Page 28
TMP89FM42
Even if the STOP pin input returns to low after the warm-up starts, the STOP mode is not restarted.
Figure 2-8 Level-sensitive Release Mode (Example when the high-frequency clock oscillation circuit is selected)
- Edge-sensitive release mode In this mode, the STOP mode is released at the rising edge of the STOP pin input. Setting SYSCR1 to "0" selects the edge-sensitive release mode. This is used in applications where a relatively short program is executed repeatedly at periodic intervals. This periodic signal (for example, a clock from a low-power consumption oscillator) is input to the STOP pin. In the edge-sensitive release mode, the STOP mode is started even when the STOP pin input is high
Example: Starting the STOP mode from the NORMAL mode (Warm-up time at release of the STOP mode is about 200ms at fc=10 MHz.)
LD LD DI LD (SYSCR1) , 0x80 (WUCCR),0x01 (WUCDR),0x20 ; WUCCR = 00 (No division) (Note) ; Sets the warm-up time ; 200ms / 6.4s = 31.25 round up to 0x20 ; IMF = 0 ; Starts the STOP mode with the edge-sensitive release mode selected
Note: When the STOP mode is released, the warm-up counter source clock automatically changes to the clock that generated the main system clock when the STOP mode was started, regardless of WUCCR.
STOP pin
VIH
XOUT pin NORMAL mode The STOP mode is started by the program. STOP mode
Warm-up
NORMAL mode
STOP mode
The STOP mode is released by the hardware at the rising edge of the STOP pin input.
Note: If the rising edge is input to the STOP pin within 1 machine cycle after SYSCR1 is set to "1", the STOP mode will not be released.
Figure 2-9 Edge-sensitive Release Mode (Example when the high-frequency clock oscillation circuit is selected)
RA001
Page 29
2. CPU Core
2.3 System clock controller TMP89FM42
2. Release by the key-on wakeup The STOP mode is released by inputting the prescribed level to the key-on wakeup pin. The level to release the STOP mode can be selected from "H" and "L". For release by the key-on wakeup, refer to section "Key-on Wakeup".
Note: If the key-on wakeup pin input becomes the opposite level to the release level after the warm-up starts, the STOP mode is not restarted.
3. Release by the voltage detection circuits The STOP mode is released by the supply voltage detection by the voltage detection circuits. To release the STOP mode by using the voltage detection circuits, set VDCR2 to "01" or "10". If the voltage detection operation mode of the voltage detection circuits is set to generate reset signals (when VDCR2 is 1 (x=1 to 2)), the STOP mode is released and a reset is applied as soon as the supply voltage becomes lower than the detection voltage. When the supply voltage becomes equal to or higher than the detection voltage of the voltage detection circuits, the reset is released and the warm-up starts. After the warm-up is completed, the NORMAL1 mode becomes active. If the voltage detection operation mode of the voltage detection circuits is set to generate interrupt request signals (when VDCR2 is 0 (x=1 to 2)), the STOP mode is released when the supply voltage becomes equal to or higher than the detection voltage. For details, refer to the section of the voltage detection circuits.
Note: If the supply voltage becomes equal to or higher than the detection voltage within 1 machine cycle after SYSCR1 is set to "1", the STOP mode will not be released.
(3)
STOP mode release operation The STOP mode is released in the following sequence: 1. Oscillation starts. For the oscillation start operation in each mode, refer to "Table 2-4 Oscillation Start Operation at Release of the STOP Mode". 2. Warm-up is executed to secure the time required to stabilize oscillation. The internal operations remain stopped during warm-up. The warm-up time is set by the warm-up counter, depending on the oscillator characteristics. 3. After the warm-up time has elapsed, the normal operation is restarted by the instruction that follows the STOP mode start instruction. At this time, the prescaler and the divider of the timing generator are cleared to "0".
Note: When the STOP mode is released with a low hold voltage, the following cautions must be observed. The supply voltage must be at the operating voltage level before releasing the STOP mode. The RESET pin input must also be "H" level, rising together with the supply voltage. In this case, if an external time constant circuit has been connected, the RESET pin input voltage will increase at a slower pace than the power supply voltage. At this time, there is a danger that a reset may occur if the input voltage level of the RESET pin drops below the non-inverting high-level input voltage (Hysteresis input).
RA001
Page 30
TMP89FM42
Table 2-4 Oscillation Start Operation at Release of the STOP Mode
Operation mode before the STOP mode is started High-frequency clock High-frequency clock oscillation circuit Low-frequency clock Oscillation start operation after release The high-frequency clock oscillation circuit starts oscillation. The low-frequency clock oscillation circuit stops oscillation. The high-frequency clock oscillation circuit starts oscillation. The low-frequency clock oscillation circuit starts oscillation. The high-frequency clock oscillation circuit stops oscillation. The low-frequency clock oscillation circuit starts oscillation.
Single-clock mode
NORMAL1
-
NORMAL2 Dual-clock mode SLOW1
High-frequency clock oscillation circuit
Low-frequency clock oscillation circuit
-
Low-frequency clock oscillation circuit
Note: When the operation returns to the NORMAL2 mode, fc is input to the frequency division circuit of the warm-up counter.
2.3.6.2
IDLE1/2 and SLEEP1 modes
The IDLE1/2 and SLEEP1 modes are controlled by the system control register 2 (SYSCR2) and maskable interrupts. The following states are maintained during these modes. 1. The CPU and the watchdog timer stop their operations. The peripheral circuits continue to operate. 2. The data memory, the registers, the program status word and the port output latches are all held in the status in effect before IDLE1/2 or SLEEP1 mode was started. 3. The program counter holds the address of the instruction 2 ahead of the instruction which starts the IDLE1/2 or SLEEP1 mode.
RA001
Page 31
2. CPU Core
2.3 System clock controller TMP89FM42
Starting IDLE1/2 mode or SLEEP1 mode by an instruction
CPU and WDT stop
Reset input No No Interrupt request Yes No (Normal release mode)
Yes
Reset
IMF = "1" Yes (Interrupt release mode)
Interrupt processing
Execution of the instruction which follows the IDLE1/2 mode or SLEEP1 mode start instruction
Figure 2-10 IDLE1/2 and SLEEP 1 Modes
RA001
Page 32
TMP89FM42
(1)
Start the IDLE1/2 and SLEEP1 modes After the interrupt master enable flag (IMF) is set to "0", set the individual interrupt enable flag (EF) to "1", which releases IDLE1/2 and SLEEP1 modes. To start the IDLE1/2 or SLEEP1 mode, set SYSCR2 to "1". If the release condition is satisfied when it is attempted to start the IDLE1/2 or SLEEP1 mode, SYSCR2 remains cleared and the IDLE1/2 or SLEEP1 mode will not be started.
Note 1: When a watchdog timer interrupt is generated immediately before the IDLE1/2 or SLEEP1 mode is started, the watchdog timer interrupt will be processed but the IDLE1/2 or SLEEP1 mode will not be started. Note 2: Before starting the IDLE1/2 or SLEEP1 mode, enable the interrupt request signals to be generated to release the IDLE1/2 or SLEEP1 mode and set the individual interrupt enable flag.
(2)
Release the IDLE1/2 and SLEEP1 modes The IDLE1/2 and SLEEP1 modes include a normal release mode and an interrupt release mode. These modes are selected at the interrupt master enable flag (IMF). After releasing IDLE1/2 or SLEEP1 mode, SYSCR2 is automatically cleared to "0" and the operation mode is returned to the mode preceding the IDLE1/2 or SLEEP1 mode. The IDLE1/2 and SLEEP1 modes are also released by a reset by the RESET pin, a power-on reset and a reset by the voltage detection circuits. After releasing the reset, the warm-up starts. After the warm-up is completed, the NORMAL1 mode becomes active. * Normal release mode (IMF = "0") The IDLE1/2 or SLEEP1 mode is released when the interrupt latch enabled by the individual interrupt enable flag (EF) is "1". The operation is restarted by the instruction that follows the IDLE1/2 or SLEEP1 mode start instruction. Normally, the interrupt latch (IL) of the interrupt source used for releasing must be cleared to "0" by load instructions. * Interrupt release mode (IMF = "1") The IDLE1/2 or SLEEP1 mode is released when the interrupt latch enabled by the individual interrupt enable flag (EF) is "1". After the interrupt is processed, the operation is restarted by the instruction that follows the IDLE1/2 or SLEEP1 mode start instruction.
2.3.6.3
IDLE0 and SLEEP0 modes
The IDLE0 and SLEEP0 modes are controlled by the system control register 2 (SYSCR2) and the time base timer control register (TBTCR). The following states are maintained during the IDLE0 and SLEEP0 modes: * The timing generator stops the clock supply to the peripheral circuits except the time base timer. * The data memory, the registers, the program status word and the port output latches are all held in the states in effect before the IDLE0 or SLEEP0 mode was started. * The program counter holds the address of the instruction 2 ahead of the instruction which starts the IDLE0 or SLEEP0 mode.
RA001
Page 33
2. CPU Core
2.3 System clock controller TMP89FM42
Stopping peripherals by instructions
Starting IDLE0 or SLEEP0 mode by an instruction
CPU and WDT stop
Reset input No No
TBT source clock falling edge
Yes
Reset
Yes "0" TBTCR "1" No TBT interrupt enabled Yes No IMF = "1" Yes (Interrupt release mode)
(Normal release mode)
Interrupt processing
Execution of the instruction which follows the IDLE0 or SLEEP0 mode start instruction
Figure 2-11 IDLE0 and SLEEP0 Modes
* Start the IDLE0 and SLEEP0 modes Stop (disable) the peripherals such as a timer counter. To start the IDLE0 or SLEEP0 mode, set SYSCR2 to "1". * Release the IDLE0 and SLEEP0 modes The IDLE0 and SLEEP0 modes include a normal release mode and an interrupt release mode. These modes are selected at the interrupt master enable flag (IMF), the individual interrupt enable flag (EF5) for the time base timer and TBTCR. After releasing the IDLE0 or SLEEP0 mode, SYSCR2 is automatically cleared to "0" and the operation mode is returned to the mode preceding the IDLE0 or SLEEP0 mode. If TBTCR has been set at "1", the INTTBT interrupt latch is set. The IDLE0 and SLEEP0 modes are also released by a reset by the RESET pin, a power-on reset and a reset by the voltage detection circuits. When a reset is released, the warm-up starts. After the warm-up is completed, the NORMAL1 mode becomes active.
RA001
Page 34
TMP89FM42
(1)
Normal release mode (IMF, EF5, TBTCR = "0") The IDLE0 or SLEEP0 mode is released when the falling edge of the source clock selected at TBTCR is detected. After the IDLE0 or SLEEP0 mode is released, the operation is restarted by the instruction that follows the IDLE0 or SLEEP0 mode start instruction. When TBTCR is "1", the time base timer interrupt latch is set.
(2)
Interrupt release mode (IMF, EF5, TBTCR = "1") The IDLE0 or SLEEP0 mode is released when the falling edge of the source clock selected at TBTCR is detected. After the release, the INTTBT interrupt processing is started.
Note 1: The IDLE0 or SLEEP0 mode is released to the NORMAL1 or SLOW1 mode by the asynchronous internal clock selected at TBTCR. Therefore, the period from the start to the release of the mode may be shorter than the time specified at TBTCR. Note 2: When a watchdog timer interrupt is generated immediately before the IDLE0 or SLEEP0 mode is started, the watchdog timer interrupt will be processed but the IDLE0 or SLEEP0 mode will not be started.
2.3.6.4
SLOW mode
The SLOW mode is controlled by system control register 2 (SYSCR2).
(1)
Switching from the NORMAL2 mode to the SLOW1 mode Set SYSCR2 to "1". When a maximum of 2/fcgck + 10/fs [s] has elapsed since SYSCR2 is set to "1", the main system clock (fm) is switched to fs/4. After switching, wait for 2 machine cycles or longer, and then clear SYSCR2 to "0" to turn off the high-frequency clock oscillator. If the oscillation of the low-frequency clock (fs) is unstable, confirm the stable oscillation at the warm-up counter before implementing the procedure described above.
Note 1: Be sure to follow this procedure to switch the operation from the NORMAL2 mode to the SLOW1 mode. Note 2: It is also possible to allow the basic clock for the high-frequency clock to oscillate continuously to return to NORMAL2 mode. However, be sure to turn off the oscillation of the basic clock for the high-frequency clock when the STOP mode is started from the SLOW mode. Note 3: After switching SYSCR2, be sure to wait for 2 machine cycles or longer before clearing SYSCR2 to "0". Clearing it within 2 machine cycles causes a system clock reset. Note 4: When the main system clock (fm) is switched, the gear clock (fcgck) is synchronized with the clock that is a quarter of the basic clock (fs) for the low-frequency clock. For the synchronization, fm is stopped for a period of 10/fs or shorter.
Quarter of the low-frequency clock (fs/4) Gear clock (fcgck)
SYSCR2
Main system clock
10/fs (max.) When the rising edge of fcgck is When the rising edge of fs/4 is detected detected twice after SYSCR2 twice after fm is stopped, fm is switched to fs. is changed from 0 to 1, f is stopped for synchronization.
Figure 2-12 Switching of the Main System Clock (fm) (Switching from fcgck to fs/4)
RA001 Page 35
2. CPU Core
2.3 System clock controller TMP89FM42
Example 1: Switching from the NORMAL2 mode to the SLOW1 mode (when fc is used as the basic clock for the high-frequency clock)
SET (SYSCR2).4 ; SYSCR2 = 1 ; (Switches the main system clock to the basic clock for the low-frequency clock for the SLOW2 mode) NOP NOP CLR (SYSCR2).6 ; SYSCR2 = 0 (Turns off the high-frequency clock oscillation circuit) ; Waits for 2 machine cycles
Example 2: Switching to the SLOW1 mode after the stable oscillation of the low-frequency clock oscillation circuit is confirmed at the warm-up counter (fs=32.768KHz, warm-up time = about 100 ms)
; #### Initialize routine #### SET | | LD LD (WUCCR), 0x02 (WUCDR), 0x33 ; WUCCR = 00 (No division) WUCCR = 1 (Selects fs as the source clock) ; Sets the warm-up time (Determines the time depending on the oscillator characteristics) 100 ms/1.95 ms = 51.2 round up to 0x33 ; Enables INTWUC interrupts ; SYSCR2 = 1 (Starts the low-frequency clock oscillation and starts the warm-up counter) (P0FC).2 ; P0FC2 = 1 (Uses P02/03 as oscillators)
SET SET
(EIRL).4 (SYSCR2).5
| ; #### Interrupt service routine of warm-up counter interrupts #### PINTWUC: SET NOP NOP CLR RETI | VINTWUC: DW PINTWUC ; INTWUC vector table (SYSCR2).6 ; SYSCR2 = 0 (Turns off the high-frequency clock oscillation circuit) (SYSCR2).4 ; SYSCR2 = 1 (Switches the main system clock to the low-frequency clock) ; Waits for 2 machine cycles
(2)
Switching from the SLOW1 mode to the NORMAL1 mode Set SYSCR2 to "1" to enable the high-frequency clock (fc) to oscillate. Confirm at the warm-up counter that the oscillation of the basic clock for the high-frequency clock has stabilized, and then clear SYSCR2 to "0". When a maximum of 8/fs + 2.5/fcgck [s] has elapsed since SYSCR2 is cleared to "0", the main system clock (fm) is switched to fcgck. After switching, wait for 2 machine cycles or longer, and then clear SYSCR2 to "0" to turn off the low-frequency clock oscillator. The SLOW mode is also released by a reset by the RESET pin, a power-on reset and a reset by the voltage detection circuits. When a reset is released, the warm-up starts. After the warm-up is completed, the NORMAL1 mode becomes active.
Note 1: Be sure to follow this procedure to switch the operation from the SLOW1 mode to the NORMAL1 mode. Note 2: After switching SYSCR2, be sure to wait for 2 machine cycles or longer before clearing SYSCR2 to "0". Clearing it within 2 machine cycles causes a system clock reset. Note 3: When the main system clock (fm) is switched, the gear clock (fcgck) is synchronized with the clock that is a quarter of the basic clock (fs) for the low-frequency clock. For the synchronization, fm is stopped for a period of 2.5/fcgck [s] or shorter. Note 4: When P0FC0 is "0", setting SYSCR2 to "1" causes a system clock reset. Note 5: When SYSCR2 is set at "1", writing "1" to SYSCR2 does not cause the warm-up counter to start counting the source clock.
RA001
Page 36
TMP89FM42
Quarter of the low-frequency clock (fs/4) Gear clock (fcgck)
SYSCR2
2.5/fcgck(max.)
Main system clock When the rising edge of fs/4 is When the rising edge of fcgck is detected detected twice after SYSCR2 twice after fm is stopped, fm is switched to fcgck. is changed from 1 to 0, f is stopped for synchronization.
Figure 2-13 Switching the Main System Clock (fm) (Switching from fs/4 to fcgck)
Example : Switching from the SLOW1 mode to the NORMAL1 mode after the stability of the high-frequency clock oscillation circuit is confirmed at the warm-up counter (fc = 10 MHz, warm-up time = 4.0 ms)
; #### Initialize routine #### SET | | LD LD (WUCCR), 0x09 (WUCDR), 0x9D ; WUCCR = 10 (Divided by 2) WUCCR = 0 (Selects fc as the source clock) ; Sets the warm-up time (Determine the time depending on the frequency and the oscillator characteristics) 4ms / 25.6us = 156.25 round up to 0x9D ; Enables INTWUC interrupts ; SYSCR2 = 1 (Starts the oscillation of the high-frequency clock oscillation circuit) (P0FC).2 ; P0FC2 = 1 (Uses P02/03 as oscillators)
SET SET |
(EIRL). 4 (SYSCR2) .6
; #### Interrupt service routine of warm-up counter interrupts #### PINTWUC: CLR NOP NOP CLR RETI | VINTWUC: DW PINTWUC ; INTWUC vector table (SYSCR2). 5 ; SYSCR2 = 0 (Turns off the low-frequency clock oscillation circuit) (SYSCR2). 4 ; SYSCR2 = 0 (Switches the main system clock to the gear clock) ; Waits for 2 machine cycles
RA001
Page 37
2. CPU Core
2.4 Reset Control Circuit TMP89FM42
2.4 Reset Control Circuit
The reset circuit controls the external and internal factor resets and initializes the system.
2.4.1
Configuration
The reset control circuit consists of the following reset signal generation circuits: 1. External reset input (external factor) 2. Power-on reset (internal factor) 3. Voltage detection reset 1 (internal factor) 4. Voltage detection reset 2 (internal factor) 5. Watchdog timer reset (internal factor) 6. System clock reset (internal factor) 7. Trimming data reset (internal factor) 8. Flash standby reset (internal factor)
P10(RESET) Power-on reset signal
P10 port
Internal factor reset detection status register, Voltage detection circuit reset signal External reset input enable reset signal
Voltage detection reset 1 signal Voltage detection reset 2 signal Watchdog timer reset signal System clock reset signal Trimming data reset signal Flash standby reset signal
Warm-up counter
Warm-up counter reset signal
CPU/peripheral circuits reset signal
System clock control circuit
Figure 2-14 Reset Control Circuit
2.4.2
Control
The reset control circuit is controlled by system control register 3 (SYSCR3), system control register 4 (SYSCR4), system control status register (SYSSR4) and the internal factor reset detection status register (IRSTSR).
System control register 3
SYSCR3 (0x0FDE) 7 Bit Symbol Read/Write After reset R 0 6 R 0 5 R 0 4 R 0 3 R 0 2 (RVCTR) R/W 0 1 (RAREA) R/W 0 0 RSTDIS R/W 0
RSTDIS
External reset input enable register
0 : Enables the external reset input. 1 : Disables the external reset input.
Note 1: The enabled SYSCR3 is initialized by a power-on reset only, and cannot be initialized by an external reset input or internal factor reset. The value written in SYSCR3 is reset by a power-on reset, external reset input or internal factor reset. Note 2: The value of SYSCR3 is invalid until 0xB2 is written into SYSCR4.
RA001
Page 38
TMP89FM42
Note 3: After SYSCR3 is modified, SYSCR4 should be written 0xB2 (Enable code for SYSCR3) in NORMAL1 mode when fcgck is fc/4 (CGCR=00). Otherwise, SYSCR3 may be enabled at unexpected timing. Note 4: Bits 7 to 3 of SYSCR3 are read as "0".
System control register 4
SYSCR4 (0x0FDF) 7 Bit Symbol Read/Write After reset 0 0 0 0 6 5 4 SYSCR4 W 0 0 0 0 3 2 1 0
SYSCR4
Writes the SYSCR3 data control code.
0xB2 : Enables the contents of SYSCR3. 0xD4 : Enables the contents of SYSCR3 and SYSCR3 . 0x71 : Enables the contents of IRSTSR Others : Invalid
Note 1: SYSCR4 is a write-only register, and must not be accessed by using a read-modify-write instruction, such as a bit operation. Note 2: After SYSCR3 is modified, SYSCR4 should be written 0xB2 (Enable code for SYSCR3) in NORMAL mode when fcgck is fc/4 (CGCR=00). Otherwise, SYSCR3 may be enabled at unexpected timing. Note 3: After IRSTSR is modified, SYSCR4 should be written 0x71 (Enable code for IRSTSR in NORMAL mode when fcgck is fc/4 (CGCR=00). Otherwise, IRSTSR may be enabled at unexpected timing.
System control status register 4
SYSSR4 (0x0FDF) 7 Bit Symbol Read/Write After reset R 0 6 R 0 5 R 0 4 R 0 3 R 0 2 (RVCTRS) R 0 1 (RAREAS) R 0 0 RSTDISS R 0
RSTDISS
External reset input enable status
0 : The enabled SYSCR3 data is "0". 1 : The enabled SYSCR3 data is "1".
Note 1: The enabled SYSCR3 is initialized by a power-on reset only, and cannot be initialized by any other reset signals. The value written in SYSCR3 is reset by a power-on reset and other reset signals. Note 2: Bits 7 to 3 of SYSCR4 are read as "0".
Internal factor reset detection status register
IRSTSR (0x0FCC) 7 Bit Symbol Read/Write After reset FCLR W 0 6 FLSRF R 0 5 TRMDS R 0 4 TRMRF R 0 3 LVD2RF R 0 2 LVD1RF R 0 1 SYSRF R 0 0 WDTRF R 0
RA001
Page 39
2. CPU Core
2.4 Reset Control Circuit TMP89FM42
FCLR
Flag initialization control
0 :1 : Clears the internal factor reset flag to "0". 0 :1 : Detects the flash standby reset. 0 :1 : Detect state of abnormal trimming data 0 :1 : Detects the trimming data reset. 0 :1 : Detects the voltage detection 2 reset. 0 :1 : Detects the voltage detection 1 reset. 0 :1 : Detects the system clock reset. 0 :1 : Detects the watchdog timer reset.
FLSRF
Flash standby reset detection flag
TRMDS
Trimming data status
TRMRF
Trimming data reset detection flag
LVD2RF
Voltage detection reset 2 detection flag
LVD1RF
Voltage detection reset 1 detection flag
SYSRF
System clock reset detection flag
WDTRF
Watchdog timer reset detection flag
Note 1: IRSTSR is initialized by an external reset input or power-on reset. Note 2: Care must be taken in system designing since the IRSTSR may not fulfill its functions due to disturbing noise and other effects. Note 3: IRSTSR is initialized by a power-on reset, an external reset input or an internal reset factor. Note 4: Set IRSTSR to "1" and write 0x71 to SYSCR4. This enables IRSTSR and the internal factor reset detection status register is clear to "0". IRSTSR is cleared to "0" automatically after initializing the internal factor reset detection status register. Note 5: After IRSTSR is modified, SYSCR4 should be written 0x71 (Enable code for IRSTSR in NORMAL mode when fcgck is fc/4 (CGCR=00). Otherwise, IRSTSR may be enabled at unexpected timing. Note 6: Bit 7 of IRSTSR is read as "0".
2.4.3
Functions
The power-on reset, external reset input and internal factor reset signals are input to the warm-up circuit of the clock generator. During reset, the warm-up counter circuit is reset, and the CPU and the peripheral circuits are reset. After reset is released, the warm-up counter starts counting the high frequency clock (fc), and executes the warm-up operation that follows reset release. During the warm-up operation that follows reset release, the trimming data is loaded from the non-volatile exclusive use memory for adjustment of the ladder resistor that generates the comparison voltage for the power-on reset and the voltage detection circuits. When the warm-up operation that follows reset release is finished, the CPU starts execution of the program from the reset vector address stored in addresses 0xFFFE to 0xFFFF. When a reset signal is input during the warm-up operation that follows reset release, the warm-up counter circuit is reset. The reset operation is common to the power-on reset, external reset input and internal factor resets, except for the initialization of some special function registers and the initialization of the voltage detection circuits. When a reset is applied, the peripheral circuits become the states as shown in Table 2-5.
RA001
Page 40
TMP89FM42
Table 2-5 Initialization of Built-in Hardware by Reset Operation and Its Status after Release
Built-in hardware During reset During the warm-up operation that follows reset release MCU mode: 0xFFFE Serial PROM mode:0x01FF 0x00FF Indeterminate Indeterminate 0 Indeterminate Indeterminate Indeterminate Indeterminate Indeterminate Indeterminate 0 0 0 Oscillation enabled Oscillation disabled Start 0 Disabled Disabled or enabled HiZ Refer to the SFR map. Immediately after the warm-up operation that follows reset release MCU mode: 0xFFFE Serial PROM mode:0x01FF 0x00FF Indeterminate Indeterminate 0 Indeterminate Indeterminate Indeterminate Indeterminate Indeterminate Indeterminate 0 0 0 Oscillation enabled Oscillation disabled Stop 0 Enabled Disabled or enabled HiZ Refer to the SFR map.
Program counter (PC)
MCU mode: 0xFFFE Serial PROM mode:0x01FF 0x00FF Indeterminate Indeterminate 0 Indeterminate Indeterminate Indeterminate Indeterminate Indeterminate Indeterminate 0 0 0 Oscillation enabled Oscillation disabled Reset 0 Disabled Disabled or enabled HiZ Refer to the SFR map.
Stack pointer (SP) RAM General-purpose registers (W, A, B, C, D, E, H, L, IX and IY) Register bank selector (RBS) Jump status flag (JF) Zero flag (ZF) Carry flag (CF) Half carry flag (HF) Sign flag (SF) Overflow flag (VF) Interrupt master enable flag (IMF) Individual interrupt enable flag (EF) Interrupt latch (IL) High-frequency clock oscillation circuit Low-frequency clock oscillation circuit Warm-up counter Timing generator prescaler and divider Watchdog timer Voltage detection circuit I/O port pin status Special function register
Note: The voltage detection circuits are disabled by an external reset input or power-on reset only.
2.4.4
Reset Signal Generating Factors
Reset signals are generated by each factor as follows:
2.4.4.1
External reset input (RESET pin input)
Port P10 is also used as the RESET pin, and it serves as the RESET pin after the power is turned on. If the supply voltage is lower than the recommended operating voltage range, for example, when the power is turned on, the supply voltage is raised to the operating voltage range with the RESET pin kept at the "L" level, and a reset is applied 5 s after the oscillation is stabilized. If the supply voltage is within the recommended operating voltage range, the RESET pin is kept at the "L" level for 5 s with the stabilized oscillation, and then a reset is applied. In each case, after a reset is applied, it is released by turning the RESET pin to "H" and the warm-up operation that follows reset release gets started.
RA001
Page 41
2. CPU Core
2.4 Reset Control Circuit TMP89FM42
Note: When the supply voltage is equal to or lower than the detection voltage of the power-on reset circuit, the power-on reset remains active, even if the RESET pin is turned to "H".
Operating voltage
Reset time RESET pin CPU/peripheral circuits reset During reset Warm-up operation CPU and peripheral circuits start operation
Figure 2-15 External Reset Input (when the power is turned on)
Operating voltage
Reset time RESET pin During reset Reset signal Warm-up operation CPU and peripheral circuits start operation
Figure 2-16 External Reset Input (when the power is stabilized)
RA001
Page 42
TMP89FM42
2.4.4.2
Power-on reset
The power-on reset is an internal factor reset that occurs when the power is turned on. When power supply voltage goes on, if the supply voltage is equal to or lower than the releasing voltage of the power-on reset circuit, a reset signal is generated and if it is higher than the releasing voltage of the power-on reset circuit, a reset signal is released. When power supply voltage goes down, if the supply voltage is equal to or lower than the detecting voltage of the power-on reset circuit, a reset signal is generated. Refer to "Power-on Reset circuit".
2.4.4.3
Voltage detection reset
The voltage detection reset is an internal factor reset that occurs when it is detected that the supply voltage has reached a predetermined detection voltage. Refer to "Voltage Detection Circuit".
2.4.4.4
Watchdog timer reset
The watchdog timer reset is an internal factor reset that occurs when an overflow of the watchdog timer is detected. Refer to "Watchdog Timer".
2.4.4.5
System clock reset
The system clock reset is an internal factor reset that occurs when it is detected that the oscillation enable register is set to a combination that puts the CPU into deadlock. Refer to "Clock Control Circuit".
2.4.4.6
Trimming data reset
The trimming data reset is an internal factor reset that occurs when the trimming data latched in the internal circuit is broken down during operation due to noise or other factors. The trimming data is a data bit provided for adjustment of the ladder resistor that generates the comparison voltage for the power-on reset and the voltage detection circuits. This bit is loaded from the non-volatile exclusive use memory during the warm-up time that follows reset release (tPWUP) and latched into the internal circuit. If the trimming data loaded from the non-volatile exclusive use memory during the warm-up operation that follows reset release is abnormal, IRSTSR is set to "1". When IRSTSR is read as "1" in the initialize routine immediately after reset release, the trimming data need to be reloaded by generating an internal factor reset, such as a system clock reset, and activating the warm-up operation again. If IRSTSR is still set to "1" after repeated reading, the detection voltage of the voltage detection circuit and power-on reset circuit does not satisfy the characteristic specified in the electric characteristics. Design the system so that the system will not be damaged in such a case.
2.4.4.7
Flash standby reset
The flash standby reset is an internal factor reset generated by the reading or writing of data of the flash memory while it is on standby. Refer to "Flash Memory".
RA001
Page 43
2. CPU Core
2.4 Reset Control Circuit TMP89FM42
2.4.4.8
Internal factor reset detection status register
By reading the internal factor reset detection status register IRSTSR after the release of an internal factor reset, except the power-on reset, the factor which causes a reset can be detected. The internal factor reset detection status register is initialized by an external reset input or power-on reset. Set IRSTSR to "1" and write 0x71 to SYSCR4. This enables IRSTSR and the internal factor reset detection status register is clear to "0". IRSTSR is cleared to "0" automatically after initializing the internal factor reset detection status register.
Note 1: Care must be taken in system designing since the IRSTSR may not fulfill its functions due to disturbing noise and other effects. Note 2: After IRSTSR is modified, SYSCR4 should be written 0x71 (Enable code for IRSTSR in NORMAL mode when fcgck is fc/4 (CGCR=00). Otherwise, IRSTSR may be enabled at unexpected timing.
2.4.4.9
How to use the external reset input pin as a port
To use the external reset input pin as a port, keep the external reset input pin at the "H" level until the power is turned on and the warm-up operation that follows reset release is finished. After the warm-up operation that follows reset release is finished, set P1PU0 to "1" and P1CR0 to "0", and connect a pull-up resistor for a port. Then set SYSCR3 to "1" and write 0xB2 to SYSCR4. This disables the external reset function and makes the external reset input pin usable as a normal port. To use the pin as an external reset pin when it is used as a port, set P1PU0 to "1" and P1CR0 to "0" and connect the pull-up resistor to put the pin to the input mode. Then clear SYSCR3 to "0" and write 0xB2 to SYSCR4. This enables the external reset function and makes the pin usable as the external reset input pin.
Note 1: If you switch the external reset input pin to a port or switch the pin used as a port to the external reset input pin, do it when the pin is stabilized at the "H" level. Switching the pin function when the "L" level is input may cause a reset. Note 2: If the external reset input is used as a port, the statement which clears SYSCR3 to "0" is not written in a program. By the abnormal execution of program, the external reset input set as a port may be changed as the external reset input at unexpected timing. Note 3: After SYSCR3 is modified, SYSCR4 should be written 0xB2 (Enable code for SYSCR3) in NORMAL1 mode when fcgck is fc/4 (CGCR=00). Otherwise, SYSCR3 may be enabled at unexpected timing.
RA001
Page 44
TMP89FM42
2.5 Revision History
Rev
Description "2.3.4.1 Warm-up counter operation when the oscillation is enabled by the hardware" Fixed specification from T.B.D. to 0x66.
RA001 "Figure 2-15 External Reset Input (when the power is turned on)" and "Figure 2-16 External Reset Input (when the power is stabilized)" Deleted "Recommended".
RA001
Page 45
2. CPU Core
2.5 Revision History TMP89FM42
RA001
Page 46
TMP89FM42
3. Interrupt Control Circuit
The TMP89FM42 has a total of 25 interrupt sources excluding reset. Interrupts can be nested with priorities. Three of the internal interrupt sources are non-maskable while the rest are maskable. Interrupt sources are provided with interrupt latches (IL), which hold interrupt requests, and have independent vector addresses. When a request for an interrupt is generated, its interrupt latch is set to "1", which requests the CPU to accept the interrupt. Acceptance of interrupts is enabled or disabled by software using the interrupt master enable flag (IMF) and individual enable flag (EF) for each interrupt source. If multiple maskable interrupts are generated simultaneously, the interrupts are accepted in order of descending priority. The priorities are determined by the interrupt priority change control register (ILPRS1-ILPRS6) as Levels and determined by the hardware as the basic priorities. However, there are no prioritized interrupt sources among non-maskable interrupts.
Interrupt sources
Enable condition
Interrupt latch
Vector Address (MCU mode) RVCTR=0 enabled 0xFFFE 0xFFFC 0xFFFC 0xFFF8 0xFFF6 0xFFF4 0xFFF2 0xFFF0 0xFFEE 0xFFEC 0xFFEA 0xFFE8 0xFFE6 0xFFE4 0xFFE2 0xFFE0 0xFFDE 0xFFDC 0xFFDA 0xFFD8 0xFFD6 0xFFD4 0xFFD2 0xFFD0 0xFFCE 0xFFCC RVCTR=1 enabled 0x01FC 0x01FC 0x01F8 0x01F6 0x01F4 0x01F2 0x01F0 0x01EE 0x01EC 0x01EA 0x01E8 0x01E6 0x01E4 0x01E2 0x01E0 0x01DE 0x01DC 0x01DA 0x01D8 0x01D6 0x01D4 0x01D2 0x01D0 0x01CE 0x01CC -
Basic priority
Internal/ External Internal Internal Internal Internal Internal Internal Internal External Internal Internal Internal Internal Internal Internal Internal External External External External External Internal Internal Internal Internal Internal -
(Reset) INTSWI INTUNDEF INTWDT INTWUC INTTBT INTRXD0 / INTSIO0 INTTXD0 INT5 INTVLTD INTADC INTRTC INTTC00 INTTC01 INTTCA0 INTSBI0/INTSIO0 INT0 INT1 INT2 INT3 INT4 INTTCA1 INTRXD1 INTTXD1 INTTC02 INTTC03 -
Non-maskable Non-maskable Non-maskable Non-maskable IMF AND EIRL = 1 IMF AND EIRL = 1 IMF AND EIRL = 1 IMF AND EIRL = 1 IMF AND EIRH = 1 IMF AND EIRH = 1 IMF AND EIRH = 1 IMF AND EIRH = 1 IMF AND EIRH = 1 IMF AND EIRH = 1 IMF AND EIRH = 1 IMF AND EIRH = 1 IMF AND EIRE = 1 IMF AND EIRE = 1 IMF AND EIRE = 1 IMF AND EIRE = 1 IMF AND EIRE = 1 IMF AND EIRE = 1 IMF AND EIRE = 1 IMF AND EIRE = 1 IMF AND EIRD = 1 IMF AND EIRD = 1 -
ILL ILL ILL ILL ILL ILH ILH ILH ILH ILH ILH ILH ILH ILE ILE ILE ILE ILE ILE ILE ILE ILD ILD -
1 2 2 2 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 -
Note 1: To use the watchdog timer interrupt (INTWDT), clear WDCTR to "0" (It is set for the "Reset request" after reset is released). For details, see "Watchdog Timer". Note 2: 0xFFFA and 0xFFFB function not as interrupt vectors but as option codes in the serial PROM mode. For details, see "Serial PROM Mode". Note 3: Vector address areas can be changed by the SYSCR3 setting. To assign vector address areas to RAM, set SYSCR3 to "1" and SYSCR3 to "1".
RA003
Page 47
3. Interrupt Control Circuit
TMP89FM42
Note 4: Do not set SYSCR3 to "0" in the serial PROM mode. If an interrupt is generated with SYSCR3 ="0", the software refers to the vector area in the BOOTROM and the user cannot use it.
RA003
Page 48
Non-maskable interrupts
Interrupt source 17
IL17 IL18 IL19 IL20 IL21
4 4 4
21
Maskable interrupt priority change circuit
Interrupt source 18
Maskable interrupts
RA003
Priority encoder
1 S R IL3 Decoder 4 5 6 4 4 4 10 4 11 12 13 14 15 16 17 4 4 4 18 19 20 S R IMF Q 4 4 4 4 4 4 9 8 7 IL3 3 Q IDLE1/2,SLEEP1/2 Mode clear request Interrupt request
INTSWI INTUNDEF
Internal factor reset
INTWDT
3.1 Configuration
IL3 vector read signal
Interrupt source 4 R IL4 IL5 IL6 IL7 IL8 IL9 IL10 IL11 IL12 IL13 IL14 IL15 IL16 IL4
S
Q
A3 2 B1 0 EN
IL4 clear signal IL4 vector read signal
Interrupt source 5
Interrupt source 6
Interrupt source 7
Interrupt source 8
Interrupt source 9
Interrupt source 10
IMF (Interrupt master enable flag)
Interrupt source 11
Figure 3-1 Interrupt Control Circuit
IL25
4
Page 49
ILPRS6
Interrupt source 12
Interrupt source 13
Interrupt accept DI instruction Internal factor reset Instruction to write "0" to IMF [RET1]1 instruction (only when the IMF is set to "1" before interrupt acceptance) Instruction to write "1" to IMF [EI] instruction [RETN] instruction (only when the IMF is set to "1" before interrupt acceptance)
Interrupt source 14
Interrupt source 15
Interrupt source 16
Interrupt source 19
Interrupt source 20
25
Interrupt source25
ILPRS1
ILPRS2
ILPRS3
ILPRS4
EF25 to EF4 IL25 to IL4 reading
Data bus Address bus
Vector address generation
TMP89FM42
3. Interrupt Control Circuit
3.2 Interrupt Latches (IL25 to IL3) TMP89FM42
3.2 Interrupt Latches (IL25 to IL3)
An interrupt latch is provided for each interrupt source, except for a software interrupt and an undefined instruction execution interrupt. When an interrupt request is generated, the latch is set to "1", and the CPU is requested to accept the interrupt if its acceptance is enabled. The interrupt latch is cleared to "0" immediately after the interrupt is accepted. All interrupt latches are initialized to "0" during reset. The interrupt latches are located at addresses 0x0FE0, 0x0FE1, 0x0FE2, 0x0FE3 in SFR area. Each latch can be cleared to "0" individually by an instruction. However, IL2 and IL3 interrupt latches cannot be cleared by instructions. Do not use any read-modify-write instruction, such as a bit manipulation or operation instruction, because it may clear interrupt requests generated while the instruction is executed. Interrupt latches cannot be set to "1" by using an instruction. Writing "1" to an interrupt latch is equivalent to denying clearing of the interrupt latch, and not setting the interrupt latch. Since interrupt latches can be read by instructions, the status of interrupt requests can be monitored by software.
Note: In the main program, before manipulating an interrupt latch (IL), be sure to clear the master enable flag (IMF) to "0" (Disable interrupt by DI instruction). Then set the IMF to "1" as required after operating the IL (Enable interrupt by EI instruction). In the interrupt service routine, the IMF becomes "0" automatically and need not be cleared to "0" normally. However, if using multiple interrupt in the interrupt service routine, manipulate the IL before setting the IMF to "1".
Example 1: Clears interrupt latches
DI LD LD EI (ILL), 0y00111111 (ILH), 0y11101000 ; IMF 0 ; IL7 to IL6 0 ; IL12, IL10 to IL8 0 ; IMF 1
Example 2: Reads interrupt latches
LD WA, (ILL) ; W ILH, A ILL
Example 3: Tests interrupt latches
TEST JR (ILL). 7 F, SSET ; if IL7=1 then jump ;
RA003
Page 50
TMP89FM42
3.3 Interrupt Enable Register (EIR)
The interrupt enable register (EIR) enables and disables the acceptance of interrupts, except for the non-maskable interrupts (software interrupt, undefined instruction interrupt and watchdog interrupt). Non-maskable interrupts are accepted regardless of the contents of the EIR. The EIR consists of the interrupt master enable flag (IMF) and the individual interrupt enable flags (EF). These registers are located at addresses 0x003A, 0x003B, 0x003C, 0x003D in the SFR area, and they can be read and written by instructions (including read-modify-write instructions such as bit manipulation or operation instructions).
3.3.1
Interrupt master enable flag (IMF)
The interrupt master enable flag (IMF) enables and disables the acceptance of all maskable interrupts. Clearing the IMF to "0" disables the acceptance of all maskable interrupts. Setting the IMF to "1" enables the acceptance of the interrupts that are specified by the individual interrupt enable flags. When an interrupt is accepted, the IMF is stacked and then cleared to "0", which temporarily disables the subsequent maskable interrupts. After the interrupt service routine is executed, the stacked data, which was the status before interrupt acceptance, reloaded on the IMF by return interrupt instruction [RETI]/[RETN]. The IMF is located on bit 0 in EIRL (Address: 0x03A in SFR), and can be read and written by instructions. The IMF is normally set and cleared by [EI] and [DI] instructions respectively. During reset, the IMF is initialized to "0".
3.3.2
Individual interrupt enable flags (EF25 to EF4)
Each of these flags enables and disables the acceptance of its maskable interrupt. Setting the corresponding bit of an individual interrupt enable flag to "1" enables acceptance of its interrupt, and setting the bit to "0" disables acceptance. During reset, all the individual interrupt enable flags are initialized to "0" and no maskable interrupts are accepted until the flags are set to "1".
Note:In the main program, before manipulating the interrupt enable flag (EF), be sure to clear the master enable flag (IMF) to "0" (Disable interrupt by DI instruction). Then set the IMF to "1" as required after operating the EF (Enable interrupt by EI instruction). In the interrupt service routine, the IMF becomes "0" automatically and need not be cleared to "0" normally. However, if using multiple interrupt in the interrupt service routine, manipulate the EF before setting the IMF to "1".
Example: Enables interrupts individually and sets IMF
DI LDW : : EI ; IMF 1 (EIRL), 0y1110100010100000 ; IMF 0 ; EF15 to EF13, EF11, EF7, EF5 1 ; Note: IMF should not be set.
RA003
Page 51
3. Interrupt Control Circuit
3.3 Interrupt Enable Register (EIR) TMP89FM42
Interrupt latch (ILL)
ILL (0x0FE0) Bit Symbol Read/Write After reset Function 7 IL7 R/W 0 INTTXD0 6 IL6 R/W 0 INTRXD0 / INTSIO0 5 IL5 R/W 0 INTTBT 4 IL4 R/W 0 INTWUC 3 IL3 R 0 INTWDT 2 R 0 1 R 0 0 R 0
Interrupt latch (ILH)
ILH (0x0FE1) Bit Symbol Read/Write After reset Function 7 IL15 R/W 0 INTSBI0/ INTSIO0 6 IL14 R/W 0 INTTCA0 5 IL13 R/W 0 INTTC01 4 IL12 R/W 0 INTTC00 3 IL11 R/W 0 INTRTC 2 IL10 R/W 0 INTADC 1 IL9 R/W 0 INTVLTD 0 IL8 R/W 0 INT5
Interrupt latch (ILE)
ILE (0x0FE2) Bit Symbol Read/Write After reset Function 7 IL23 R/W 0 INTTXD1 6 IL22 R/W 0 INTRXD1 5 IL21 R/W 0 INTTCA1 4 IL20 R/W 0 INT4 3 IL19 R/W 0 INT3 2 IL18 R/W 0 INT2 1 IL17 R/W 0 INT1 0 IL16 R/W 0 INT0
Interrupt latch (ILD)
ILD (0x0FE3) Bit Symbol Read/Write After reset Function 7 R 0 6 R 0 5 R 0 4 R 0 3 R 0 2 R 0 1 IL25 R/W 0 INTTC03 0 IL24 R/W 0 INTTC02
Read 0: 1: Interrupt latch No interrupt request Interrupt request
Write Clears the interrupt request (Notes 2 and 3) Does not clear the interrupt request (Interrupt is not set by writing "1".) -
IL25 to IL4
IL3
0: 1:
No interrupt request Interrupt request
Note 1: IL3 is a read-only register. Writing the register does not affect interrupt latch. Note 2: In the main program, before manipulating an interrupt latch (IL), be sure to clear the interrupt master enable flag (IMF) to "0" (Disable interrupt by DI instruction). Then set the IMF to "1" as required after operating the IL (Enable interrupt by EI instruction). In the interrupt service routine, the IMF becomes "0" automatically and need not be cleared to "0" normally. However, if using multiple interrupt in the interrupt service routine, manipulate the IL before setting the IMF to "1". Note 3: Do not clear IL with read-modify-write instructions such as bit operations. Note 4: When a read instruction is executed on ILL, bits 0 to 2 are read as "0". Other unused bits are read as "0".
RA003
Page 52
TMP89FM42
Interrupt enable register (EIRL)
EIRL (0x003A) Bit Symbol Read/Write After reset 7 EF7 R/W 0 INTTXD0 Function 6 EF6 R/W 0 INTRXD0 / INTSIO0 5 EF5 R/W 0 INTTBT 4 EF4 R/W 0 INTWUC 3 R 0 2 R 0 1 R 0 0 IMF R/W 0 Interrupt master enable flag
Interrupt enable register (EIRH)
EIRH (0x003B) Bit Symbol Read/Write After reset Function 7 EF15 R/W 0 INTSBI0/ INTSIO0 6 EF14 R/W 0 INTTCA0 5 EF13 R/W 0 INTTC01 4 EF12 R/W 0 INTTC00 3 EF11 R/W 0 INTRTC 2 EF10 R/W 0 INTADC 1 EF9 R/W 0 INTVLTD 0 EF8 R/W 0 INT5
Interrupt enable register (EIRE)
EIRE (0x003C) Bit Symbol Read/Write After reset Function 7 EF23 R/W 0 INTTXD1 6 EF22 R/W 0 INTRXD1 5 EF21 R/W 0 INTTCA1 4 EF20 R/W 0 INT4 3 EF19 R/W 0 INT3 2 EF18 R/W 0 INT2 1 EF17 R/W 0 INT1 0 EF16 R/W 0 INT0
Interrupt enable register (EIRD)
EIRD (0x003D) Bit Symbol Read/Write After reset Function 7 R 0 6 R 0 5 R 0 4 R 0 3 R/W 0 2 R/W 0 1 EF25 R/W 0 INTTC03 0 EF24 R/W 0 INTTC02
EF25 to EF4 IMF
Individual interrupt enable flag (Specified for each bit) Interrupt master enable flag
0: 1: 0: 1:
Disables the acceptance of each maskable interrupt. Enables the acceptance of each maskable interrupt. Disables the acceptance of all maskable interrupts. Enables the acceptance of all maskable interrupts.
Note 1: Do not set the IMF and the interrupt enable flag (EF15 to EF4) to "1" at the same time. Note 2: In the main program, before manipulating the interrupt enable flag (EF), be sure to clear the master enable flag (IMF) to "0" (Disable interrupt by DI instruction). Then set the IMF to "1" as required after operating the EF (Enable interrupt by EI instruction) In the interrupt service routine, the IMF becomes "0" automatically and need not be cleared to "0" normally. However, if using multiple interrupt in the interrupt service routine, manipulate the EF before setting the IMF to "1". Note 3: When a read instruction is executed on EIRL, bits 3 to 1 are read as "0". Other unused bits are read as "0".
RA003
Page 53
3. Interrupt Control Circuit
3.4 Maskable Interrupt Priority Change Function TMP89FM42
3.4 Maskable Interrupt Priority Change Function
The priority of maskable interrupts (IL4 to IL25) can be changed to four levels, Levels 0 to 3, regardless of the basic priorities 5 to 26. Interrupt priorities can be changed by the interrupt priority change control register (ILPRS1 to ILPRS6). To raise the interrupt priority, set the Level to a larger number. To lower the interrupt priority, set the Level to a smaller number. When different maskable interrupts are generated simultaneously at the same level, the interrupt with higher basic priority is processed preferentially. For example, when the ILPRS1 register is set to 0xC0 and interrupts IL4 and IL7 are generated at the same time, IL7 is preferentially processed (provided that EF4 and EF7 have been enabled). After reset is released, all maskable interrupts are set to priority level 0 (the lowest priority).
Note: In the main program, before manipulating the interrupt priority change control register (ILPRS1 to 6), be sure to clear the master enable flag (IMF) to "0" (Disable interrupt by DI instruction). Set the IMF to "1" as required after operating ILPRS1 to 6 (Enable interrupt by EI instruction). In the interrupt service routine, the IMF becomes "0" automatically and need not be cleared to "0" normally. However, if using multiple interrupt in the interrupt service routine, manipulate ILPRS1 to 6 before setting the IMF to "1".
Interrupt priority change control register 1
ILPRS1 (0x0FF0) Bit Symbol Read/Write After reset 0 7 IL07P R/W 0 0 6 5 IL06P R/W 0 0 4 3 IL05P R/W 0 0 2 1 IL04P R/W 0 0
IL07P IL06P IL05P IL04P
Sets the interrupt priority of IL7. Sets the interrupt priority of IL6. Sets the interrupt priority of IL5. Sets the interrupt priority of IL4.
00: 01: 10: 11:
Level 0 (lower priority) Level 1 Level 2 Level 3 (higher priority)
Interrupt priority change control register 2
ILPRS2 (0x0FF1) Bit Symbol Read/Write After reset 0 7 IL11P R/W 0 0 6 5 IL10P R/W 0 0 4 3 IL09P R/W 0 0 2 1 IL08P R/W 0 0
IL11P IL10P IL09P IL08P
Sets the interrupt priority of IL11. Sets the interrupt priority of IL10. Sets the interrupt priority of IL9. Sets the interrupt priority of IL8.
00: 01: 10: 11:
Level 0 (lower priority) Level 1 Level 2 Level 3 (higher priority)
Interrupt priority change control register 3
ILPRS3 (0x0FF2) Bit Symbol Read/Write After reset 0 7 IL15P R/W 0 0 6 5 IL14P R/W 0 0 4 3 IL13P R/W 0 0 2 1 IL12P R/W 0 0
IL15P IL14P IL13P IL12P
Sets the interrupt priority of IL15. Sets the interrupt priority of IL14. Sets the interrupt priority of IL13. Sets the interrupt priority of IL12.
00: 01: 10: 11:
Level 0 (lower priority) Level 1 Level 2 Level 3 (higher priority)
RA003
Page 54
TMP89FM42
Interrupt priority change control register 4
ILPRS4 (0x0FF3) Bit Symbol Read/Write After reset 0 7 IL19P R/W 0 0 6 5 IL18P R/W 0 0 4 3 IL17P R/W 0 0 2 1 IL16P R/W 0 0
IL19P IL18P IL17P IL16P
Sets the interrupt priority of IL19. Sets the interrupt priority of IL18. Sets the interrupt priority of IL17. Sets the interrupt priority of IL16.
00: 01: 10: 11:
Level 0 (lower priority) Level 1 Level 2 Level 3 (higher priority)
Interrupt priority change control register 5
ILPRS5 (0x0FF4) Bit Symbol Read/Write After reset 0 7 IL23P R/W 0 0 6 5 IL22P R/W 0 0 4 3 IL21P R/W 0 0 2 1 IL20P R/W 0 0
IL23P IL22P IL21P IL20P
Sets the interrupt priority of IL23. Sets the interrupt priority of IL22. Sets the interrupt priority of IL21. Sets the interrupt priority of IL20.
00: 01: 10: 11:
Level 0 (lower priority) Level 1 Level 2 Level 3 (higher priority)
Interrupt priority change control register 6
ILPRS6 (0x0FF5) Bit Symbol Read/Write After reset 0 7 R/W 0 0 6 5 R/W 0 0 4 3 IL25P R/W 0 0 2 1 IL24P R/W 0 0
IL25P IL24P
Sets the interrupt priority of IL25. Sets the interrupt priority of IL24.
00: 01: 10: 11:
Level 0 (lower priority) Level 1 Level 2 Level 3 (higher priority)
RA003
Page 55
3. Interrupt Control Circuit
3.5 Interrupt Sequence TMP89FM42
3.5 Interrupt Sequence
"0"
An interrupt request, which raised interrupt latch, is held, until interrupt is accepted or interrupt latch is cleared to by resetting or an instruction. Interrupt acceptance sequence requires 8-machine cycles after the completion of the current instruction. The interrupt service task terminates upon execution of an interrupt return instruction [RETI] (for maskable interrupts) or [RETN] (for non-maskable interrupts).
3.5.1
Initial Setting
Using an interrupt requires specifying an SP (stack pointer) for it in advance. The SP is a 16-bit register pointing at the start address of a stack. The SP is post-decremented when a subroutine call or a push instruction is executed or when an interrupt request is accepted. It is pre-incremented when a return or pop instruction is executed. Therefore, the stack becomes deeper toward lower stack location addresses. Be sure to reserve a stack area having an appropriate size based on the SP setting. The SP is initialized to 00FFH after a reset. If you need to change the SP, do so right after a reset or when the interrupt master enable flag (IMF) is "0".
Example :SP setting
LD LD ADD SP, 023FH SP, SP+04H SP, 0010H ; SP = 023FH ; SP = SP + 04H ; SP = SP + 0010H
3.5.2
Interrupt acceptance processing
Interrupt acceptance processing is packaged as follows. 1. The interrupt master enable flag (IMF) is cleared to "0" in order to disable the acceptance of any following interrupt. 2. The interrupt latch (IL) for the interrupt source accepted is cleared to "0". 3. The contents of the program counter (PC) and the program status word, including the interrupt master enable flag (IMF), are saved (Pushed) on the stack in sequence of PSW + IMF, PCH, PCL. Meanwhile, the stack pointer (SP) is decremented by 3. 4. The entry address (Interrupt vector) of the corresponding interrupt service program, loaded on the vector table, is transferred to the program counter. 5. The instruction stored at the entry address of the interrupt service program is executed.
Note:When the contents of PSW are saved on the stack, the contents of register bank and IMF are also saved.
Example: Correspondence between vector table address for INTTBT and the entry address of the interrupt service program
Vector table address Vector table address
0xFFF4 0xFFF5
0x03 0xD2
0xD203 0xD204
0x0F 0x06
Figure 3-2 Vector table address and Entry address
RA003
Page 56
TMP89FM42
A maskable interrupt is not accepted until the IMF is set to "1" even if the maskable interrupt is requested in the interrupt service routine. In order to utilize nested interrupt service, the IMF must be set to "1" in the interrupt service program. In this case, acceptable interrupt sources are selectively enabled by the individual interrupt enable flags. To avoid overloaded nesting, clear the individual interrupt enable flag whose interrupt is currently serviced, before setting IMF to "1". As for non-maskable interrupt, keep interrupt service shorter compared with length between interrupt requests.
3.5.3
Saving/restoring general-purpose registers
During interrupt acceptance processing, the program counter (PC) and the program status word (PSW, includes IMF) are automatically saved on the stack, but the general purpose registers are not. These registers must be saved by software if necessary. When multiple interrupt services are nested, it is also necessary to avoid using the same data memory area for saving registers. The following methods are used to save/restore the general-purpose registers.
3.5.3.1
Using PUSH and POP instructions
To save only a specific register, PUSH and POP instructions are available.
Example :Using PUSH and POP instructions
PINTxx PUSH Interrupt processing POP RETI WA ; Restore WA register ; RETURN WA ; Save WA register
SP A SP PCL PCH PSW At Acceptance of an Interrupt W PCL PCH PSW At execution of PUSH instruction SP PCL PCH PSW At execution of POP instruction SP
Address (Example) b-4 b-3 b-2 b-1 b At execution of an RETI instruction
Figure 3-3 Saving/restoring general-purpose registers
RA003
Page 57
3. Interrupt Control Circuit
3.5 Interrupt Sequence TMP89FM42
3.5.3.2
Using data transfer instructions
To save only a specific register without nested interrupts, data transfer instructions are available.
Example :Save/store register using data transfer instructions
PINTxx: LD Interrupt processing LD RETI A, (GSAVA) ; Restore A register ; RETURN (GSAVA), A ; Save A register
Main task Interrupt acceptance Interrupt service task Saving registers
Interrupt return
Restoring registers
Figure 3-4 Saving/Restoring General-purpose Registers under Interrupt Processing
3.5.3.3
Using a register bank to save/restore general-purpose registers
In non-multiple interrupt handling, the register bank function can be used to save/restore the generalpurpose registers at a time. The register bank function saves (switches) the general-purpose registers by executing a register bank manipulation instruction (such as LD RBS,1) at the beginning of an interrupt service task. It is unnecessary to re-execute the register bank manipulation instruction at the end of the interrupt service task because executing the RETI instruction makes a return automatically to the register bank that was being used by the main task according to the content of the PSW.
Note: Two register banks (BANK0 and BANK1) are available. Each bank consists of 8-bit general-purpose registers (W, A, B, C, D, E, H, and L) and 16-bit general-purpose registers (IX and IY).
Example :Saving/restoring registers, using an instruction for transfer with data memory (with the main task using the register bank BANK0)
PINTxx: LD Interrupt processing RETI ; RETURN (Makes a return automatically to BANK0 that was being used by the main task when the PSW is restored) RBS, 1 ; Switches to the register bank BANK1
RA003
Page 58
TMP89FM42
Main task Interrupt acceptance Interrupt service task
The register bank BANK0 is in use. LD (RBS),1 Switching occurs to the register bank BANK1.
Interrupt return
A return is made automatically to the register bank BANK0.
Figure 3-5 Saving/Restoring General-purpose Registers under Interrupt Processing
3.5.4
Interrupt return
Interrupt return instructions [RETI]/[RETN] perform as follows.
[RETI]/[RETN] Interrupt Return 1. Program counter (PC) and program status word (register bank) are restored from tha stack. 2. Stack pointer (SP) is incremented by 3.
RA003
Page 59
3. Interrupt Control Circuit
3.6 Software Interrupt (INTSW) TMP89FM42
3.6 Software Interrupt (INTSW)
Executing the SWI instruction generates a software interrupt and immediately starts interrupt processing (INTSW is the top-priority interrupt). Use the SWI instruction only for address error detection or for debugging described below.
3.6.1
Address error detection
0xFF is read if for some cause such as noise the CPU attempts to fetch an instruction from a non-existent memory address. Code 0xFF is an SWI instruction, so a software interrupt is generated and an address error is detected. The address error detection range can be further expanded by writing 0xFF to unused areas in the program memory.
3.6.2
Debugging
Debugging efficiency can be increased by placing the SWI instruction at the software break point setting address.
3.7 Undefined Instruction Interrupt (INTUNDEF)
When the CPU tries to fetch and execute an instruction that is not defined, INTUNDEF is generated and starts the interrupt processing. INTUNDEF is accepted even if another non-maskable interrupt is in process. The current process is discontinued and the INTUNDEF interrupt process starts soon after it is requested.
Note: The undefined instruction interrupt (INTUNDEF) forces the CPU to jump into the interrupt vector address, as software interrupt (SWI) does.
RA003
Page 60
TMP89FM42
3.8 Revision History
Rev Revised from WDTCR1 to WDCTR RA003 Added chapter "3.5 Interrupt Sequence"
Description
"Figure 3-3 Saving/restoring general-purpose registers" Revised SP position
RA003
Page 61
3. Interrupt Control Circuit
3.8 Revision History TMP89FM42
RA003
Page 62
TMP89FM42
4. External Interrupt control circuit
External interrupts detects the change of the input signal and generates an interrupt request. Noise can be removed by the built-in digital noise canceller.
4.1 Configuration
The external interrupt control circuit consists of a noise canceller, an edge detection circuit, a level detection circuit and an interrupt signal generation circuit. Externally input signals are input to the rising edge or falling edge or level detection circuit for each external interrupt, after noise is removed by the noise canceller.
INTj pin
Noise canceller
Falling edge detection circuit
Interrupt request signal generation circuit
INTj interr request j=0,5
fcgck
fs/4
Figure 4-1 External Interrupts 0/5
INTi pin fs/4
Noise canceller
Rising edge detection circuit Falling edge detection circuit INTiES INTiLVL
Interrupt request signal generation circuit
INTi interrupt request i=1 to 3
Z A B C DS
fcgck
1234
EINTCRi
Figure 4-2 External Interrupts 1/2/3
Rising edge detection circuit INT4 pin fs A B C DS INT4ES INT4LVL Z Noise canceller Falling edge detection circuit Level detection circuit
Interrupt request signal generation circuit
INT4 interrupt request
fcgck
1234
EINTCR4
Figure 4-3 External Interrupt 4
RA000
Page 63
4. External Interrupt control circuit
4.2 Control TMP89FM42
4.2 Control
External interrupts are controlled by the following registers: Low power consumption register 3
POFFCR3 (0x0F77) Bit Symbol Read/Write After reset 7 R/W 0 6 R/W 0 5 INT5EN R/W 0 4 INT4EN R/W 0 3 INT3EN R/W 0 2 INT2EN R/W 0 1 INT1EN R/W 0 0 INT0EN R/W 0
INT5EN
INT5 control
0 1 0 1 0 1 0 1 0 1 0 1
Disable Enable Disable Enable Disable Enable Disable Enable Disable Enable Disable Enable
INT4EN
INT4 control
INT3EN
INT3 control
INT2EN
INT2 control
INT1EN
INT1 control
INT0EN
INT0 control
Note 1: Clearing INTxEN(x=0 to 5) to "0" stops the clock supply to the external interrupts. This invalidates the data written in the control register for each external interrupt. When using the external interrupts, set INTxEN to "1" and then write data into the control register for each external interrupt. Note 2: Interrupt request signals may be generated when INTxEN is changed. Before changing INTxEN, clear the corresponding interrupt enable register to "0" to disable the generation of interrupt. When the operation mode is changed from NORMAL1/2 or IDLE1/2 to SLOW1/2 or SLEEP1, wait 12/fs [s] after the operation mode is changed and clear the interrupt latch. And when the operation mode is changed from SLOW1/2 or SLEEP1 to NORMAL1/ 2 or IDLE1/2, wait 2/fcgck+3/fspl [s] after the operation mode is changed and clear the interrupt latch. Note 3: Bits 7 and 6 of POFFSET3 are read as "0".
External interrupt control register 1
EINTCR1 (0x0FD8) 7 Bit Symbol Read/Write After reset R 0 6 R 0 5 R 0 4 INT1LVL R 0 3 INT1ES R/W 0 2 1 INT1NC R/W 0 0
INI1LVL
Noise canceller pass signal level when the interrupt request signal is generated for external interrupt 1
0: 1: 00 :
Initial state or signal level "L" Signal level "H" An interrupt request is generated at the rising edge of the noise canceller pass signal An interrupt request is generated at the falling edge of the noise canceller pass signal An interrupt request is generated at both edges of the noise canceller pass signal Reserved NORMAL1/2, IDLE1/2 SLOW1/2, SLEEP1 00 : 01 : 10 : 11 : fs/4 fs/4 fs/4 fs/4 [Hz] [Hz] [Hz] [Hz]
INT1ES
Selects the interrupt request generating condition for external interrupt 1
01 : 10 : 11 :
INT1NC
Sets the noise canceller sampling interval for external interrupt 1
00 : 01 : 10 : 11 :
fcgck [Hz] fcgck / 22 [Hz] fcgck / 23 [Hz] fcgck / 24 [Hz]
Note 1: fcgck: Gear clock [Hz], fs: Low-frequency clock [Hz] Note 2: Interrupt requests may be generated during transition of the operation mode. Before changing the operation mode, clear the corresponding interrupt enable register to "0" to disable the generation of interrupt. When the operation mode is changed from NORMAL1/2 or IDLE1/2 to SLOW1/2 or SLEEP1, wait 12/fs [s] after the operation mode is changed and
RA000
Page 64
TMP89FM42
clear the interrupt latch. And when the operation mode is changed from SLOW1/2 or SLEEP1 to NORMAL1/2 or IDLE1/2, wait 2/fcgck+3/fspl [s] after the operation mode is changed and clear the interrupt latch. Note 3: Interrupt requests may be generated when EINTCR1 is changed. Before doing such operation, clear the corresponding interrupt enable register to "0" to disable the generation of interrupt. When the operation mode is changed from NORMAL1/2 or IDLE1/2 to SLOW1/2 or SLEEP1, wait 12/fs [s] after the operation mode is changed and clear the interrupt latch. And when the operation mode is changed from SLOW1/2 or SLEEP1 to NORMAL1/2 or IDLE1/2, wait 2/ fcgck+3/fspl [s] after the operation mode is changed and clear the interrupt latch. Note 4: Bits 7 to 5 of EINTCR1 are read as "0".
External interrupt control register 2
EINTCR1 (0x0FD9) 7 Bit Symbol Read/Write After reset R 0 6 R 0 5 R 0 4 INT2LVL R 0 3 INT2ES R/W 0 2 1 INT2NC R/W 0 0
INI2LVL
Noise canceller pass signal level when the interrupt request signal is generated for external interrupt 2
0: 1: 00 :
Initial state or signal level "L" Signal level "H" An interrupt request is generated at the rising edge of the noise canceller pass signal An interrupt request is generated at the falling edge of the noise canceller pass signal An interrupt request is generated at both edges of the noise canceller pass signal Reserved NORMAL1/2, IDLE1/2 SLOW1/2, SLEEP1 00 : 01 : 10 : 11 : fs/4 fs/4 fs/4 fs/4 [Hz] [Hz] [Hz] [Hz]
INT2ES
Selects the interrupt request generating condition for external interrupt 2
01 : 10 : 11 :
INT2NC
Sets the noise canceller sampling interval for external interrupt 2
00 : 01 : 10 : 11 :
fcgck [Hz] fcgck / 22 [Hz] fcgck / 23 [Hz] fcgck / 24 [Hz]
Note 1: fcgck: Gear clock [Hz], fs: Low-frequency clock [Hz] Note 2: Interrupt requests may be generated during transition of the operation mode. Before changing the operation mode, clear the corresponding interrupt enable register to "0" to disable the generation of interrupt. When the operation mode is changed from NORMAL1/2 or IDLE1/2 to SLOW1/2 or SLEEP1, wait 12/fs [s] after the operation mode is changed and clear the interrupt latch. And when the operation mode is changed from SLOW1/2 or SLEEP1 to NORMAL1/2 or IDLE1/2, wait 2/fcgck+3/fspl [s] after the operation mode is changed and clear the interrupt latch. Note 3: Interrupt requests may be generated when EINTCR2 is changed. Before doing such operation, clear the corresponding interrupt enable register to "0" to disable the generation of interrupt. When the operation mode is changed from NORMAL1/2 or IDLE1/2 to SLOW1/2 or SLEEP1, wait 12/fs [s] after the operation mode is changed and clear the interrupt latch. And when the operation mode is changed from SLOW1/2 or SLEEP1 to NORMAL1/2 or IDLE1/2, wait 2/ fcgck+3/fspl [s] after the operation mode is changed and clear the interrupt latch. Note 4: Bits 7 to 5 of EINTCR2 are read as "0".
External interrupt control register 3
EINTCR3 (0x0FDA) 7 Bit Symbol Read/Write After reset R 0 6 R 0 5 R 0 4 INT3LVL R 0 3 INT3ES R/W 0 2 1 INT3NC R/W 0 0
RA000
Page 65
4. External Interrupt control circuit
4.2 Control TMP89FM42
INI3LVL
Noise canceller pass signal level when the interrupt request signal is generated for external interrupt 3
0: 1: 00 :
Initial state or signal level "L" Signal level "H" An interrupt request is generated at the rising edge of the noise canceller pass signal An interrupt request is generated at the falling edge of the noise canceller pass signal An interrupt request is generated at both edges of the noise canceller pass signal Reserved NORMAL1/2, IDLE1/2 SLOW1/2, SLEEP1 00 : 01 : 10 : 11 : fs/4 fs/4 fs/4 fs/4 [Hz] [Hz] [Hz] [Hz]
INT3ES
Selects the interrupt request generating condition for external interrupt 3
01 : 10 : 11 :
INT3NC
Sets the noise canceller sampling interval for external interrupt 3
00 : 01 : 10 : 11 :
fcgck [Hz] fcgck / 22 [Hz] fcgck / 23 [Hz] fcgck / 24 [Hz]
Note 1: fcgck: Gear clock [Hz], fs: Low-frequency clock [Hz] Note 2: Interrupt requests may be generated during transition of the operation mode. Before changing the operation mode, clear the corresponding interrupt enable register to "0" to disable the generation of interrupt. When the operation mode is changed from NORMAL1/2 or IDLE1/2 to SLOW1/2 or SLEEP1, wait 12/fs [s] after the operation mode is changed and clear the interrupt latch. And when the operation mode is changed from SLOW1/2 or SLEEP1 to NORMAL1/2 or IDLE1/2, wait 2/fcgck+3/fspl [s] after the operation mode is changed and clear the interrupt latch. Note 3: Interrupt requests may be generated when EINTCR3 is changed. Before doing such operation, clear the corresponding interrupt enable register to "0" to disable the generation of interrupt. When the operation mode is changed from NORMAL1/2 or IDLE1/2 to SLOW1/2 or SLEEP1, wait 12/fs [s] after the operation mode is changed and clear the interrupt latch. And when the operation mode is changed from SLOW1/2 or SLEEP1 to NORMAL1/2 or IDLE1/2, wait 2/ fcgck+3/fspl [s] after the operation mode is changed and clear the interrupt latch. Note 4: Bits 7 to 5 of EINTCR3 are read as "0".
External interrupt control register 4
EINTCR4 (0x0FDB) 7 Bit Symbol Read/Write After reset R 0 6 R 0 5 R 0 4 INT4LVL R 0 3 INT4ES R/W 0 2 1 INT4NC R/W 0 0
INI4LVL
Noise canceller pass signal level when the interrupt request signal is generated for external interrupt 4
0: 1: 00 :
Initial state or signal level "L" Signal level "H" An interrupt request is generated at the rising edge of the noise canceller pass signal An interrupt request is generated at the falling edge of the noise canceller pass signal An interrupt request is generated at both edges of the noise canceller pass signal An interrupt request is generated at "H" of the noise canceller pass signal NORMAL1/2, IDLE1/2 SLOW1/2, SLEEP1 00 : 01 : 10 : 11 : fs/4 fs/4 fs/4 fs/4 [Hz] [Hz] [Hz] [Hz]
INT4ES
Selects the interrupt request generating condition for external interrupt 4
01 : 10 : 11 :
INT4NC
Sets the noise canceller sampling interval for external interrupt 4
00 : 01 : 10 : 11 :
fcgck [Hz] fcgck / 22 [Hz] fcgck / 23 [Hz] fcgck / 24 [Hz]
Note 1: fcgck: Gear clock [Hz], fs: Low-frequency clock [Hz] Note 2: Interrupt requests may be generated during transition of the operation mode. Before changing the operation mode, clear the corresponding interrupt enable register to "0" to disable the generation of interrupt. When the operation mode is changed from NORMAL1/2 or IDLE1/2 to SLOW1/2 or SLEEP1, wait 12/fs [s] after the operation mode is changed and clear the interrupt latch. And when the operation mode is changed from SLOW1/2 or SLEEP1 to NORMAL1/2 or IDLE1/2, wait 2/fcgck+3/fspl [s] after the operation mode is changed and clear the interrupt latch. Note 3: Interrupt requests may be generated when EINTCR4 is changed. Before doing such operation, clear the corresponding interrupt enable register to "0" to disable the generation of interrupt. When the operation mode is changed from NORMAL1/2 or IDLE1/2 to SLOW1/2 or SLEEP1, wait 12/fs [s] after the operation mode is changed and clear the interrupt latch. And when the operation mode is changed from SLOW1/2 or SLEEP1 to NORMAL1/2 or IDLE1/2, wait 2/ fcgck+3/fspl [s] after the operation mode is changed and clear the interrupt latch.
RA000
Page 66
TMP89FM42
Note 4: The contents of EINTCRx are updated each time an interrupt request signal is generated. Note 5: Bits 7 to 5 of EINTCR4 are read as "0".
4.3 Function
The condition for generating interrupt request signals and the noise cancel time can be set for external interrupts 1 to 4. The condition for generating interrupt request signals and the noise cancel time are fixed for external interrupts 0 and 5. Table 4-1 External Interrupts
Source Pin Enable conditions Interrupt request signal generated at External interrupt pin input signal width and noise removal NORMAL1/2, IDLE1/2 Less than 1/fcgck: Noise More than 1/fcgck and less than 2/ fcgck: Indeterminate More than 2/fcgck: Signal Less than 2/fspl: Noise More than 2/fspl and less than 3/fspl+1/ fcgck: Indeterminate More than 3/fspl+1/fcgck: Signal Less than 2/fspl: Noise More than 2/fspl and less than 3/fspl+1/ fcgck: Indeterminate More than 3/fspl+1/fcgck: Signal Less than 2/fspl: Noise More than 2/fspl and less than 3/fspl+1/ fcgck: Indeterminate More than 3/fspl+1/fcgck: Signal Less than 2/fspl: Noise More than 2/fspl and less than 3/fspl+1/ fcgck: Indeterminate More than 3/fspl+1/fcgck: Signal Less than 1/fcgck: Noise More than 1/fcgck and less than 2/ fcgck: Indeterminate More than 2/fcgck: Signal SLOW1/2, SLEEP1 Less than 4/fs: Noise More than 4/fs and less than 8/fs: Indeterminate More than 8/fs: Signal Less than 4/fs: Noise More than 4/fs and less than 8/fs: Indeterminate More than 8/fs: Signal Less than 4/fs: Noise More than 4/fs and less than 8/fs: Indeterminate More than 8/fs: Signal Less than 4/fs: Noise More than 4/fs and less than 8/fs: Indeterminate More than 8/fs: Signal Less than 4/fs: Noise More than 4/fs and less than 8/fs: Indeterminate More than 8/fs: Signal Less than 4/fs: Noise More than 4/fs and less than 8/fs: Indeterminate More than 8/fs: Signal
INT0
INT0
IMF AND EF16 = 1
Falling edge
INT1
INT1
IMF AND EF17 = 1
Falling edge Rising edge Both edges
INT2
INT2
IMF AND EF18 = 1
Falling edge Rising edge Both edges
INT3
INT3
IMF AND EF19 = 1
Falling edge Rising edge Both edges Falling edge Rising edge Both edges "H" level
INT4
INT4
IMF AND EF20 = 1
INT5
INT5
IMF AND EF8 = 1
Falling edge
Note 1: fcgck, Gear clock [Hz]; fs, low frequency clock [Hz]; fspl, Sampling interval [Hz]
4.3.1
Low power consumption function
External interrupts have a function that saves power by using the low power consumption register (POFFCR3) when they are not used. Setting POFFCR3 to "0" stops (disables) the basic clock for external interrupts and helps save power. Note that this makes external interrupts unavailable. Setting POFFCR3 to "1" supplies (enables) the basic clock for external interrupts and makes external interrupts available. After reset, POFFCR3 is initialized to "0" and external interrupts become unavailable. When using the external interrupt function for the first time, be sure to set POFFCR3 to "1" in the initial setting of software (before operating the external interrupt control registers).
Note:Interrupt request signals may be generated when INTxEN is changed. Before changing INTxEN, clear the corresponding interrupt enable register to "0" to disable the generation of interrupt. When the operation mode is changed from NORMAL1/2 or IDLE1/2 to SLOW1/2 or SLEEP1, wait 12/fs [s] after the operation mode is changed and clear the interrupt latch. And when the operation mode is changed from SLOW1/2 or SLEEP1 to NORMAL1/2 or IDLE1/2, wait 2/fcgck+3/fspl [s] after the operation mode is changed and clear the interrupt latch.
RA000
Page 67
4. External Interrupt control circuit
4.3 Function TMP89FM42
4.3.2
External interrupt 0
External interrupt 0 detects the falling edge of the INT0 pin and generates interrupt request signals. In NORMAL1/2 or IDLE1/2 mode, pulses of less than 1/fcgck are removed as noise and pulses of 2/fcgck or more are recognized as signals. In SLOW/SLEEP mode, pulses of less than 4/fs are removed as noise and pulses of 8/fs or more are recognized as signals.
4.3.3
External interrupts 1/2/3
External interrupts 1/2/3 detect the falling edge, the rising edge or both edges of the INT1, INT2 and INT3 pins and generate interrupt request signals.
4.3.3.1
Interrupt request signal generating condition detection function
Select interrupt request signal generating conditions at EINTCRx for external interrupts 1/2/ 3. Table 4-2 Selection of Interrupt Request Generation Edge
EINTCRx 00 01 10 11 Detected at Rising edge Falling edge Both edges Reserved
Note: x=1 to 3
4.3.3.2
A noise canceller pass signal monitoring function when interrupt request signals are generated
The level of a signal that has passed through the noise canceller when an interrupt request is generated can be read by using EINTCRx. When both edges are selected as detection edges, the edge where an interrupt is generated can be detected by reading EINTCRx.
INTi pin Signal that has passed through the noise canceller Interrupt request signal (detected at the falling edge) INT LVL
Interrupt request signal (detected at the rising edge) INT LVL
Interrupt request signal (detected at both edges) INT LVL
RA000
Page 68
TMP89FM42
Note: The contents of EINTCRx are updated each time an interrupt request signal is generated.
Figure 4-4 Interrupt Request Generation and EINTCRx
4.3.3.3
Noise cancel time selection function
In NORMAL1/2 or IDLE1/2 mode, a signal that has been sampled by fcgck is sampled at the sampling interval selected at EINTCRx. If the same level is detected three consecutive times, the signal is recognized as a signal. If not, the signal is removed as noise. Table 4-3 Noise Canceller Sampling Lock
EINTCRx 00 01 10 11 Sampling interval fcgck fcgck/22 fcgck/23 fcgck/24
INTi pin i=1 to 3 Signal after noise removal
Signal
Noise
Figure 4-5 Noise Cancel Operation
In SLOW1/2 or SLEEP1 mode, a signal is sampled by the low frequency clock divided by 4. If the same level is detected twice consecutively, the signal is recognized as a signal. In IDLE0, SLEEP0 or STOP mode, the noise canceller sampling operation is stopped and an external interrupts are unavailable. When operation returns to NORMAL1/2, IDLE1/2, SLOW1/2 or SLEEP1 mode, sampling operation restarts.
Note 1: If noise is input consecutively during sampling of external interrupt pins, the noise cancel function does not work properly. Set EINTCRx according to the cycle of externally input noise. Note 2: If an external interrupt pin is used as an output port, the input signal to the port is fixed to "L" when the mode is switched to the output mode, and thus an interrupt request occurs. To use the pin as an output port, clear the corresponding interrupt enable register to "0" to disable the generation of interrupt. Note 3: Interrupt requests may be generated during transition of the operation mode. Before changing the operation mode, clear the corresponding interrupt enable register to "0" to disable the generation of interrupt. When the operation mode is changed from NORMAL1/2 or IDLE1/2 to SLOW1/2 or SLEEP1, wait 12/fs [s] after the operation mode is changed and clear the interrupt latch. And when the operation mode is changed from SLOW1/2 or SLEEP1 to NORMAL1/2 or IDLE1/2, wait 2/ fcgck+3/fspl [s] after the operation mode is changed and clear the interrupt latch.
4.3.4
External interrupt 4
External interrupt 4 detects the falling edge, the rising edge, both edges or "H" level of the INT4 pin and generates interrupt request signals.
4.3.4.1
Interrupt request signal generating condition detection function
Select an interrupt request signal generating condition at EINTCR4 for external interrupt 4.
RA000
Page 69
4. External Interrupt control circuit
4.3 Function TMP89FM42
Table 4-4 Selection of Interrupt Request Generation Edge
EINTCR4 00 01 10 11 Detected at Rising edge Falling edge Both edges "H" level interrupt
4.3.4.2
A noise canceller pass signal monitoring function when interrupt request signals are generated
The level of a signal that has passed through the noise canceller when an interrupt request is generated can be read by using EINTCR4. When both edges are selected as detection edges, the edge where an interrupt is generated can be detected by reading EINTCR4.
INT4 pin Signal that has passed through the noise canceller Interrupt request signal (detected at the falling edge) INT4LVL
Interrupt request signal (detected at the rising edge) INT4LVL
Interrupt request signal (detected at both edges) INT4LVL Interrupt request signal (level detection) INT4LVL
Figure 4-6 Interrupt Request Generation and EINTCR4
4.3.4.3
Noise cancel time selection function
In NORMAL1/2 or IDLE1/2 mode, a signal that has been sampled by fcgck is sampled at the sampling interval selected at EINTCRx. If the same level is detected three consecutive times, the signal is recognized as a signal. If not, the signal is removed as noise.
RA000
Page 70
TMP89FM42
Table 4-5 Noise Canceller Sampling Lock
EINTCR4 00 01 10 11 Sampling interval fcgck fcgck/22 fcgck/23 fcgck/24
INT4 pin
Signal
Noise
Signal after noise removal
Figure 4-7 Noise Cancel Operation
In SLOW1/2 or SLEEP1 mode, a signal is sampled by the low frequency clock divided by 4. If the same level is detected twice consecutively, the signal is recognized as a signal. In IDLE0, SLEEP0 or STOP mode, the noise canceller sampling operation is stopped and an external interrupts are unavailable. When operation returns to NORMAL1/2, IDLE1/2, SLOW1/2 or SLEEP1 mode, sampling operation restarts.
Note 1: When noise is input consecutively during sampling external interrupt pins, the noise cancel function does not work properly. Set EINTCRx according to the cycle of externally input noise. Note 2: When an external interrupt pin is used as an output port, the input signal to the port is fixed to "L" when the mode is switched to the output mode, and thus an interrupt request occurs. To use the pin as an output port, clear the corresponding interrupt enable register to "0" to disable the generation of interrupt. Note 3: Interrupt requests may be generated during transition of the operation mode. Before changing the operation mode, clear the corresponding interrupt enable register to "0" to disable the generation of interrupt. When the operation mode is changed from NORMAL1/2 or IDLE1/2 to SLOW1/2 or SLEEP1, wait 12/fs [s] after the operation mode is changed and clear the interrupt latch. And when the operation mode is changed from SLOW1/2 or SLEEP1 to NORMAL1/2 or IDLE1/2, wait 2/ fcgck+3/fspl [s] after the operation mode is changed and clear the interrupt latch.
4.3.5
External interrupt 5
External interrupt 5 detects the falling edge of the INT5 pin and generates interrupt request signals. In NORMAL1/2 or IDLE1/2 mode, pulses of less than 1/fcgck are removed as noise and pulses of 2/fcgck or more are recognized as signals. In SLOW/SLEEP mode, pulses of less than 4/fs are removed as noise and pulses of 8/fs or more are recognized as signals.
RA000
Page 71
4. External Interrupt control circuit
4.3 Function TMP89FM42
RA000
Page 72
TMP89FM42
5. Watchdog Timer (WDT)
The watchdog timer is a fail-safe system to detect rapidly the CPU malfunctions such as endless loops due to spurious noises or the deadlock conditions, and return the CPU to a system recovery routine. The watchdog timer signals used for detecting malfunctions can be programmed as watchdog interrupt request signals or watchdog timer reset signals.
Note: Care must be taken in system designing since the watchdog timer may not fulfill its functions due to disturbing noise and other effects.
5.1 Configuration
fcgck/2 or fs/23 12 fcgck/2 or fs/25 14 fcgck/2 or fs/27 16 fcgck/2 or fs/29
Selector
10
Source clock
2
Clear
8-bit up counter 34567
8
Overflow
Interrupt request/reset signal control circuit
Watchdog timer interrupt requestl Watchdog timer reset signal
2 8 CPU/peripheral circuits reset
Clear time control circuit
Disable control circuit
Disable code (0xB1)
Clear code (0x4E)
WDTST WINTST1 WINTST2 WDTOUT WDTEN WDTW
Control code decoder WDCNT WDCDR
WDCTR
Figure 5-1 Watchdog Timer Configuration
WDTT
WDST
5.2 Control
The watchdog timer is controlled by the watchdog timer control register (WDCTR), the watchdog timer control code register (WDCDR), the watchdog timer counter monitor (WDCNT) and the watchdog timer status (WDST). The watchdog timer is enabled automatically just after the warm-up operation that follows reset is finished. Watchdog timer control register
WDCTR (0x0FD4) 7 Bit Symbol Read/Write After reset R 1 6 R 0 5 WDTEN R/W 1 0 4 WDTW R/W 0 1 3 2 WDTT R/W 1 1 0 WDTOUT R/W 0
RA000
Page 73
5. Watchdog Timer (WDT)
5.2 Control TMP89FM42
WDTEN
Enables/disables the watchdog timer operation.
0: 1: 00 : 01 :
Disable Enable The 8-bit up counter is cleared by writing the clear code at any point within the overflow time of the 8-bit up counter. A watchdog timer interrupt request is generated by writing the clear code at a point within the first quarter of the overflow time of the 8-bit up counter. The 8-bit up counter is cleared by writing the clear code after the first quarter of the overflow time has elapsed. A watchdog timer interrupt request is generated by writing the clear code at a point within the first half of the overflow time of the 8-bit up counter. The 8-bit up counter is cleared by writing the clear code after the first half of the overflow time has elapsed. A watchdog timer interrupt request is generated by writing the clear code at a point within the first three quarters of the overflow time of the 8-bit up counter. The 8-bit up counter is cleared by writing the clear code after the first three quarters of the overflow time have elapsed. NORMAL mode SLOW mode DV9CK=0 DV9CK=1 211/fs 213/fs 215/fs 217/fs 211/fs 213/fs 215/fs 217/fs
WDTW
Sets the clear time of the 8-bit up counter.
10 :
11 :
WDTT
Sets the overflow time of the 8-bit up counter.
00 : 01: 10: 11:
218/fcgck 220/fcgck 222/fcgck 224/fcgck
WDTOUT
Selects an overflow detection signal of the 8-bit up counter.
0: 1:
Watchdog timer interrupt request signal Watchdog timer reset request signal
Note 1: fcgck, Gear clock [Hz]; fs, Low frequency clock [Hz] Note 2: WDCTR, WDCTR and WDCTR cannot be changed when WDCTR is "1". If WDCTR is "1", clear WDCTR to "0" and write the disable code (0xB1) into WDCDR to disable the watchdog timer operation. Note that WDCTR, WDCTR and WDCTR can be changed at the same time as setting WDCTR to "1". Note 3: Bit 7 and bit 6 of WDCTR are read as "1" and "0" respectively.
Watchdog timer control code register
WDCDR (0x0FD5) 7 Bit Symbol Read/Write After reset 0 0 0 0 6 5 4 WDTCR2 W 0 0 0 0 3 2 1 0
WDTCR2
Writes watchdog timer control codes.
0x4E : 0xB1 : Others :
Clears the watchdog timer. (Clear code) Disables the watchdog timer operation and clears the 8-bit up counter when WDCTR is "0". (Disable code) Invalid
Note: WDCDR is a write-only register and must not be accessed by using a read-modify-write instruction, such as a bit operation.
8-bit up counter monitor
WDCNT (0x0FD6) 7 Bit Symbol Read/Write After reset 0 0 0 0 6 5 4 WDCNT R 0 0 0 0 3 2 1 0
WDCNT
Monitors the count value of the 8-bit up counter
The count value of the 8-bit up counter is read.
RA000
Page 74
TMP89FM42
Watchdog timer status
WDST (0x0FD7) 7 Bit Symbol Read/Write After reset R 0 6 R 1 5 R 0 4 R 1 3 R 1 2 WINTST2 R 0 1 WINTST1 R 0 0 WDTST R 1
WINTST2
Watchdog timer interrupt request signal factor status 2
0: 1:
No watchdog timer interrupt request signal has occurred. A watchdog timer interrupt request signal has occurred due to the overflow of the 8-bit up counter. No watchdog timer interrupt request signal has occurred. A watchdog timer interrupt request signal has occurred due to releasing of the 8-bit up counter outside the clear time. Operation disabled Operation enabled
WINTST1
Watchdog timer interrupt request signal factor status 1 Watchdog timer operating state status
0: 1:
WDTST
0: 1:
Note 1: WDST and WDST are cleared to "0" by reading WDST. Note 2: Values after reset are read from bits 7 to 3 of WDST.
5.3 Functions
The watchdog timer can detect the CPU malfunctions and deadlock by detecting the overflow of the 8-bit up counter and detecting releasing of the 8-bit up counter outside the clear time. The watchdog timer stoppage and other abnormalities can be detected by reading the count value of the 8-bit up counter at random times and comparing the value to the last read value.
5.3.1
Setting of enabling/disabling the watchdog timer operation
Setting WDCTR to "1" enables the watchdog timer operation, and the 8-bit up counter starts counting the source clock. WDCTR is initialized to "1" after the warm-up operation that follows reset is released. This means that the watchdog timer is enabled. To disable the watchdog timer operation, clear WDCTR to "0" and write 0xB1 into WDCDR. Disabling the watchdog timer operation clears the 8-bit up counter to "0".
Note:If the overflow of the 8-bit up counter occurs at the same time as 0xB1 (disable code) is written into WDCDR with WDCTR set at "1", the watchdog timer operation is disabled preferentially and the overflow detection is not executed.
To re-enable the watchdog timer operation, set WDCTR to "1". There is no need to write a control code into WDCDR.
Watchdog timer source clock 8-bit up counter value WDCTR Overflow time WDCTR Overflow time Interrupt request signal 1 clock (max.)
00H 01H FFH 00H
Figure 5-2 WDCTR Set Timing and Overflow Time
RA000 Page 75
5. Watchdog Timer (WDT)
5.3 Functions TMP89FM42
Note:The 8-bit up counter source clock operates out of synchronization with WDCTR. Therefore, the first overflow time of the 8-bit up counter after WDCTR is set to "1" may get shorter by a maximum of 1 source clock. The 8-bit up counter must be cleared within the period of the overflow time minus 1 source clock cycle.
5.3.2
Setting the clear time of the 8-bit up counter
WDCTR sets the clear time of the 8-bit up counter. When WDCTR is "00", the clear time is equal to the overflow time of the 8-bit up counter, and the 8-bit up counter can be cleared at any time. When WDCTR is not "00", the clear time is fixed to only a certain period within the overflow time of the 8-bit up counter. If the operation for releasing the 8-bit up counter is attempted outside the clear time, a watchdog timer interrupt request signal occurs. At this time, the watchdog timer is not cleared but continues counting. If the 8-bit up counter is not cleared within the clear time, a watchdog timer reset request signal or a watchdog timer interrupt request signal occurs due to the overflow, depending on the WDCTR setting.
8-bit up counter value FFH 00H 01H When WDCTR is 00 When WDCTR is 01 When WDCTR is 10 When WDCTR is 11
3FH 40H
7FH 80H
BFH C0H
FFH 00H
Clear time
Outside the clear time
Clear time Clear time Clear time
Outside the clear time
Outside the clear time
Figure 5-3 WDCTR and the 8-bit up Counter Clear Time
5.3.3
Setting the overflow time of the 8-bit up counter
WDCTR sets the overflow time of the 8-bit up counter. When the 8-bit up counter overflows, a watchdog timer reset request signal or a watchdog timer interrupt request signal occurs, depending on the WDCTR setting. If the watchdog timer interrupt request signal is selected as the malfunction detection signal, the watchdog counter continues counting, even after the overflow has occurred. The watchdog timer temporarily stops counting up in the STOP mode (including warm-up) or in the IDLE/ SLEEP mode, and restarts counting up after the STOP/IDLE/SLEEP mode is released. To prevent the 8-bit up counter from overflowing immediately after the STOP/IDLE/SLEEP mode is released, it is recommended to clear the 8-bit up counter before the operation mode is changed. Table 5-1 Watchdog Timer Overflow Time (fcgck=10.0 MHz; fs=32.768 kHz)
Watchdog timer overflow time [s] WDTT DV9CK = 0 00 01 10 11 26.21 m 104.86 m 419.43 m 1.678 NORMAL mode DV9CK = 1 62.50 m 250.00 m 1.000 4.000 SLOW mode 62.50 m 250.00 m 1.000 4.000
RA000
Page 76
TMP89FM42
Note:The 8-bit up counter source clock operates out of synchronization with WDCTR. Therefore, the first overflow time of the 8-bit up counter after WDCTR is set to "1" may get shorter by a maximum of 1 source clock. The 8-bit up counter must be cleared within a period of the overflow time minus 1 source clock cycle.
5.3.4
Setting an overflow detection signal of the 8-bit up counter
WDCTR selects a signal to be generated when the overflow of the 8-bit up counter is detected. 1. When the watchdog timer interrupt request signal is selected (when WDCTR is "0") Releasing WDCTR to "0" causes a watchdog timer interrupt request signal to occur when the 8-bit up counter overflows. A watchdog timer interrupt is a non-maskable interrupt, and its request is always accepted, regardless of the interrupt master enable flag (IMF) setting.
Note: When a watchdog timer interrupt is generated while another interrupt, including a watchdog timer interrupt, is already accepted, the new watchdog timer interrupt is processed immediately and the preceding interrupt is put on hold. Therefore, if watchdog timer interrupts are generated continuously without execution of the RETN instruction, too many levels of nesting may cause a malfunction of the microcontroller.
2. When the watchdog timer reset request signal is selected (when WDCTR is "1") Setting WDCTR to "1" causes a watchdog timer reset request signal to occur when the 8-bit up counter overflows. This watchdog timer reset request signal resets the TMP89FM42 and starts the warm-up operation.
5.3.5
Writing the watchdog timer control codes
The watchdog timer control codes are written into WDCDR. By writing 0x4E (clear code) into WDCDR, the 8-bit up counter is cleared to "0" and continues counting the source clock. When WDCTR is "0", writing 0xB1 (disable code) into WDCDR disables the watchdog timer operation. To prevent the 8-bit up counter from overflowing, clear the 8-bit up counter in a period shorter than the overflow time of the 8-bit up counter and within the clear time. By designing the program so that no overflow will occur, the program malfunctions and deadlock can be detected through interrupts generated by watchdog timer interrupt request signals. By applying a reset to the microcomputer using watchdog timer reset request signals, the CPU can be restored from malfunctions and deadlock.
Example: When WDCTR is "0", set the watchdog timer detection time to 220/fcgck [s], set the counter clear time to half of the overflow time, and allow a watchdog timer reset request signal to occur if a malfunction is detected.
LD Clear the 8-bit up counter at a point after half of its overflow time and within a period of the overflow time minus 1 source clock cycle. Clear the 8-bit up counter at a point after half of its overflow time and within a period of the overflow time minus 1 source clock cycle. (WDCTR), 0y00110011 ; WDTW10, WDTT01, WDTOUT1
LD
(WDCDR), 0x4E
; Clear the 8-bit up counter
LD
(WDCDR), 0x4E
; Clear the 8-bit up counter
Note:If the overflow of the 8-bit up counter and writing of 0x4E (clear code) into WDCDR occur simultaneously, the 8-bit up counter is cleared preferentially and the overflow detection is not executed.
RA000
Page 77
5. Watchdog Timer (WDT)
5.3 Functions TMP89FM42
5.3.6
Reading the 8-bit up counter
The counter value of the 8-bit up counter can be read by reading WDCNT. The stoppage of the 8-bit up counter can be detected by reading WDCNT at random times and comparing the value to the last read value.
5.3.7
Reading the watchdog timer status
The watchdog timer status can be read at WDST. WDST is set to "1" when the watchdog timer operation is enabled, and it is cleared to "0" when the watchdog timer operation is disabled. WDST is set to "1" when a watchdog timer interrupt request signal occurs due to the overflow of the 8-bit up counter. WDST is set to "1" when a watchdog timer interrupt request signal occurs due to the operation for releasing the 8-bit up counter outside the clear time. You can know which factor has caused a watchdog timer interrupt request signal by reading WDST and WDST in the watchdog timer interrupt service routine. WDST and WDST are cleared to "0" when WDST is read. If WDST is read at the same time as the condition for turning WDST or WDST to "1" is satisfied, WDST or WDST is set to "1", rather than being cleared.
8-bit up counter value
FFH 00H 01H
3FH 40H
7FH 80H
BFH C0H
FFH 00H 01H
When WDCTR is 10 Writing of 4EH (clear code) Reading of WDST
Outside the clear time
Clear time
Interrupt request signal generated by clearing the 8-bit up counter outside the clear time
Interrupt request signal generated by the overflow of the 8-bit up counter
Watchdog timer interrupt request signal WDST WDST
Figure 5-4 Changes in the Watchdog Timer Status
RA000
Page 78
TMP89FM42
6. Power-on Reset Circuit
The power-on reset circuit generates a reset when the power is turned on. When the supply voltage is lower than the detection voltage of the power-on reset circuit, a power-on reset signal is generated.
6.1 Configuration
The power-on reset circuit consists of a reference voltage generation circuit and a comparator. The supply voltage divided by ladder resistor is compared with the voltage generated by the reference voltage generation circuit by the comparator.
VDD Comparator Power-on reset signal
Reference voltage generation circuit
Figure 6-1 Power-on Reset Circuit
6.2 Function
When power supply voltage goes on, if the supply voltage is equal to or lower than the releasing voltage of the power-on reset circuit, a power-on reset signal is generated and if it is higher than the releasing voltage of the poweron reset circuit, a power-on reset signal is released. When power supply voltage goes down, if the supply voltage is equal to or lower than the detecting voltage of the power-on reset circuit, a power-on reset signal is generated. Until the power-on reset signal is generated, a warm-up circuit and a CPU is reset. When the power-on reset signal is released, the warm-up circuit is activated. The reset of the CPU and peripheral circuits is released after the warm-up time that follows reset release has elapsed. Increase the supply voltage into the operating range during the period from detection of the power-on reset release voltage until the end of the warm-up time that follows reset release. If the supply voltage has not reached the operating range by the end of the warm-up time that follows reset release, the TMP89FM42 cannot operate properly.
RA000
Page 79
6. Power-on Reset Circuit
6.2 Function TMP89FM42
Supply voltage (VDD) Operating voltage
VPROFF VPRON
VDD
PPW PRON PROFF
Power-on reset signal Warm-up counter start
Warm-up counter clock
PWUP
CPU/peripheral circuits reset signal
Note 1: The power-on reset circuit may operate improperly, depending on fluctuations in the supply voltage (VDD). Refer to the electrical characteristics and take them into consideration when designing equipment. Note 2: For the AC timing, refer to the electrical characteristics.
Figure 6-2 Operation Timing of Power-on Reset
RA000
Page 80
TMP89FM42
7. Voltage Detection Circuit
The voltage detection circuit detects any decrease in the supply voltage and generates voltage detection interrupt request signals and voltage detection reset signals.
Note: The voltage detection circuit may operate improperly, depending on fluctuations in the supply voltage (VDD). Refer to the electrical characteristics and take them into consideration when designing equipment.
7.1 Configuration
The voltage detection circuit consists of a reference voltage generation circuit, a detection voltage level selection circuit, a comparator and control registers. The supply voltage (VDD) is divided by the ladder resistor and input to the detection voltage selection circuit. A voltage is selected in the detection voltage selection circuit, depending on the detection voltage (VDxLVL), and compared to the reference voltage in the comparator. When the supply voltage (VDD) becomes lower than the detection voltage (VDxLVL), a voltage detection interrupt request signal or a voltage detection reset signal is generated. Either the voltage detection interrupt request signal or the voltage detection reset signal can be selected by programming the software.
VDD
Detection voltage 1 level selection circuit
F/F Voltage detection reset signal 1
Interrupt request signal generation circuit
Voltage detection interrupt request signal Voltage detection STOP mode release signal
Detection voltage 2 level selection circuit
F/F Voltage detection reset signal 2
Reference voltage generation circuit
VD2MOD
V D2 E N
VD1MOD
VD2LVL
VD1LVL
VD2SF
VD1SF
VDCR1
VDCR2
Figure 7-1 Voltage Detection Circuit
7.2 Control
The voltage detection circuit is controlled by voltage detection control registers 1,2 and 3. Voltage detection control register 1
VDCR1 (0x0FC6) 7 Bit Symbol Read/Write After reset VD2F R/W 0 6 VD2SF Read Only 0 0 5 VD2LVL R/W 0 4 3 VD1F R/W 0 2 VD1SF Read Only 0 0 1 VD1LVL R/W 0 0
V D1 E N
VD1F
VD2F
RA002
Page 81
7. Voltage Detection Circuit
7.3 Function TMP89FM42
VD2F
Voltage detection 2 flag (Retains the state when VDD0 : VDD VD2LVL 1 : VDD < VD2LVL 0 : VDD VD2LVL 1 : VDD < VD2LVL 00 : 2.35 +0.15 / -0.15V 01 : 3.15 +0.15 / -0.15V 10 : 2.85 +0.15 / -0.15V 11 : 2.65 +0.15 / -0.15V 0 : VDD VD1LVL 1 : VDD < VD1LVL 0 : VDD VD1LVL 1 : VDD < VD1LVL 00 : 4.50 +0.2 / -0.2V 01 : 4.20 +0.2 / -0.2V 10 : 3.70 +0.2 / -0.2V 11 : 3.15 +0.15 / -0.15V
VD2SF
VD2LVL
Selection for detection voltage 2
VD1F
Voltage detection 1 flag (Retains the state when VDDVD1SF
VD1LVL
Selection for detection voltage 1
Note 1: VDCR1 is initialized by a power-on reset or an external reset input. Note 2: When VD2F or VD1F is cleared by the software and is set due to voltage detection at the same time, the setting due to voltage detection is given priority. Note 3: VD2F and VD1F cannot be programmed to "1" by the software.
Voltage detection control register 2
VDCR2 (0x0FC7) 7 Bit Symbol Read/Write After reset R 0 6 R 0 0 5 SRSS R/W 0 4 3 VD2MOD R/W 0 2 VD2EN R/W 0 1 VD1MOD R/W 0 0 VD1EN R/W 0
00: 01: SRSS Selection for the STOP mode release source 10:
11: VD2MOD Selects the operation mode of voltage detection 2 Enables/disables the operation of voltage detection 2 Selects the operation mode of voltage detection 1 Enables/disables the operation of voltage detection 1 0: 1: 0: 1: 0: 1: 0: 1:
Release STOP mode depending on the state of the STOP pin Release STOP mode when the supply voltage (VDD) becomes higher than the detection voltage (VDxLVL) Release STOP mode depending on the state of the STOP pin or when the supply voltage (VDD) becomes higher than the detection voltage (VDxLVL) Reserved Generate a voltage detection interrupt request signal Generate a voltage detection reset 2 signal Disables the operation of voltage detection 2 Enables the operation of voltage detection 2 Generates a voltage detection interrupt request signal Generates a voltage detection reset signal Disables the operation of voltage detection 1 Enables the operation of voltage detection 1
VD2EN
VD1MOD
VD1EN
Note 1: VDCR2 is initialized by a power-on reset or an external reset input. Note 2: Bits 7 and 6 of VDCR2 are read as "0".
7.3 Function
Two detection voltages (VDxLVL, x=1-2) can be set in the voltage detection circuit. For each voltage, enabling/ disabling the voltage detection and the operation to be executed when the supply voltage (VDD) becomes lower than the detection voltage (VDxLVL) can be programmed.
RA002
Page 82
TMP89FM42
7.3.1
Enabling/disabling the voltage detection operation
Setting VDCR2 to "1" enables the voltage detection operation. Setting it to "0" disables the operation. VDCR2 is cleared to "0" immediately after a power-on reset or a reset by an external reset input is released.
Note:When the supply voltage (VDD) is lower than the detection voltage (VDxLVL), setting VDCR2 to "1" generates a voltage detection interrupt request signal or a voltage detection reset signal at the time.
7.3.2
Selecting the voltage detection operation mode
If the voltage detection operation mode is set to generate voltage detection interrupt request signals (VDCR1="0") and VDCR2 is set to "1", a voltage detection interrupt request signal is generated when the supply voltage (VDD) becomes lower than the detection voltage (VDxLVL). If the voltage detection operation mode is set to generate voltage detection reset signals (VDCR1="1") and VDCR2 is set to "1", a voltage detection reset signal is generated when the supply voltage (VDD) becomes lower than the detection voltage (VDxLVL). VDCR1 and VDCR2 are initialized by a power-on reset or an external reset input only. Therefore, the voltage detection reset signals are generated continuously, as long as the supply voltage (VDD) is lower than the detection voltage (VDxLVL).
Note:If the voltage detection mode is set to generate voltage detection interrupt request signals and the supply voltage (VDD) becomes lower than the detection voltage (VDxLVL) in the STOP, IDLE0 or SLEEP0 mode, a voltage detection interrupt request signal is generated after the operation mode is released and returned to NORMAL or SLOW mode.
VDD level Detection voltage level
VDCR2
Voltage detection interrupt request signal
Voltage detection reset signal
Figure 7-2 Voltage Detection Interrupt Request Signal and Voltage Detection Reset Signal
7.3.3
Selecting the detection voltage level
Select a detection voltage at VDCR1.
7.3.4
Voltage detection flag and voltage detection status flag
The magnitude relation between the supply voltage (VDD) and the detection voltage (VDxLVL) can be checked by reading VDCR1 and VDCR1. If VDCR2 is set at "1", when the supply voltage (VDD) becomes lower than the detection voltage (VDxLVL), VDCR1 is set to "1" and is held in this state. VDCR1 is not cleared to "0" when the supply voltage (VDD) becomes equal to or higher than the detection voltage (VDxLVL). When VDCR2 is cleared to "0" after VDCR1 is set to "1", the previous state is still held. To clear VDCR1, "0" must be written to it.
RA002
Page 83
7. Voltage Detection Circuit
7.3 Function TMP89FM42
If VDCR2 is set at "1", when the supply voltage (VDD) becomes lower than the detection voltage (VDxLVL), VDCR1 is set to "1". When the supply voltage (VDD) becomes equal to or higher than the detection voltage (VDxLVL), VDCR1 is cleared to "0". Unlike VDCR1, VDCR1 does not hold the set state.
Note 1: When the supply voltage (VDD) becomes lower than the detection voltage (VDxLVL) in the STOP, IDLE0 or SLEEP0 mode, the voltage detection flag and the voltage detection status flag are changed after the operation mode is returned to NORMAL or SLOW mode. Note 2: Depending on the voltage detection timing, the voltage detection status flag (VDxSF) may be changed earlier than the voltage detection flag (VDxF) by a maximum of 2/fcgck[s].
VDD level Detection voltage level
VDCR2
Write 0 to VDCR1
VDCR1
VDCR1
The flag is not set because VDCR2 is 0 .
Figure 7-3 Changes in the Voltage Detection Flag and the Voltage Detection Status Flag
7.3.5
Selecting the STOP mode release signal
By setting VDCR2 to select the voltage detection STOP mode release signal as the STOP mode release signal, STOP mode can be released when the supply voltage (VDD) becomes equal to or higher than the detection voltage (VDxLVL). To use this function, set VDCR2 to "0" and set the operation mode to generate voltage detection interrupt request signals. In addition, before the operation is switched to STOP mode, clear SYSCR1 to "0" and select the edge release mode. If the level release mode is selected and the supply voltage (VDD) is equal to or higher than the detection voltage (VDxLVL), STOP mode cannot be activated. Setting VDCR2 to "00" allows STOP mode to be released depending on the state of the STOP pin. Setting it to "01" allows STOP mode to be released when the supply voltage (VDD) becomes equal to or higher than the detection voltage (VDxLVL). Setting it to "10" allows STOP mode to be released depending on the state of the STOP pin or when the supply voltage (VDD) becomes equal to or higher than the detection voltage (VDxLVL). Refer to Section 2 "CPU" for settings to activate or release STOP mode.
Note 1: After STOP mode is released by a voltage detection STOP mode release signal, the interrupt latch becomes "1". If it is undesirable to accept an interrupt after STOP mode is released, disable interrupts before STOP mode is activated. In addition, clear the interrupt latch before enabling interrupts after STOP mode is released. Note 2: If the supply voltage (VDD) becomes equal to or higher than the detection voltage (VDxLVL) within 1 machine cycle after SYSCR1 is set to "1" and STOP mode is activated, STOP mode is not released. Note 3: When the voltage detection interrupt request signal of the voltage detection circuit is used as the STOP mode release signal, take into account sudden fluctuations in the supply voltage (VDD) and changes near the detection voltage (VDxLVL) in setting the detection voltage (VDxLVL) and the warm-up time.
RA002
Page 84
TMP89FM42
VDD level Detection voltage level
VDCR1 Voltage detection interrupt request signal NORMAL mode STOP mode STOP mode is activated by programming. Warm-up NORMAL mode STOP mode STOP mode is activated by programming. Warm-up NORMAL mode
STOP mode is released at the falling edge of VDCR1
STOP mode is released at the falling edge of VDCR1
Figure 7-4 STOP Mode Release by VDCR1
7.4 Register Settings
7.4.1 Setting procedure when the operation mode is set to generate voltage detection interrupt request signals
When the operation mode is set to generate voltage detection interrupt request signal, make the following setting: In this case, setting VDCR2 allows STOP mode to be released when the supply voltage (VDD) becomes equal to or higher than the detection voltage (VDxLVL). 1. Clear the voltage detection circuit interrupt enable flag to "0". 2. Set the detection voltage at VDCR1(x=1 to 2). 3. Clear VDCR2 to "0" to set the operation mode to generate voltage detection interrupt request signals. 4. Set VDCR2 to "1" to enable the voltage detection operation. 5. Wait for 5 [us] or more until the voltage detection circuit becomes stable. 6. Make sure that VDCR1 is "0". 7. Clear the voltage detection circuit interrupt latch to "0" and set the interrupt enable flag to "1" to enable interrupts.
Note:If the set value of detection voltage (VDxLVL) is close to the supply voltage (VDD), voltage detection request signals may be generated frequently. At the return from the voltage detection interrupt processing, execute appropriate wait processing depending on fluctuations in the system power supply and clear the interrupt latch.
7.4.2
Setting procedure when the operation mode is set to generate voltage detection reset signals
When the operation mode is set to generate voltage detection reset signals, make the following setting: 1. Clear the voltage detection circuit interrupt enable flag to "0". 2. Set the detection voltage at VDCR1(x=1 to 2). 3. Clear VDCR2 to "0" to set the operation mode to generate voltage detection interrupt request signals. 4. Set VDCR2 to "1" to enable the voltage detection operation. 5. Wait for 5 [us] or more until the voltage detection circuit becomes stable. 6. Make sure that VDCR1 is "0". 7. Set VDCR2 to "1" to set the operation mode to generate voltage detection reset signals.
Note 1: VDCR1 and VDCR2 are initialized by a power-on reset or an external reset input only. If the supply voltage (VDD) becomes lower than the detection voltage (VDxLVL) in the period from release of the voltage detection reset until clearing of VDCR2 to "0", a voltage detection reset signal is generated immediately.
RA002
Page 85
7. Voltage Detection Circuit
7.4 Register Settings TMP89FM42
Note 2: The voltage detection reset signals are generated continuously as long as the supply voltage (VDD) is lower than the detection voltage (VDxLVL).
RA002
Page 86
TMP89FM42
7.5 Revision History
Rev RA001 RA002
Description " Voltage detection control register 1" Revised VD1LVL and VD2LVL. Revised from VDCR2 to VDCR1
RA002
Page 87
7. Voltage Detection Circuit
7.5 Revision History TMP89FM42
RA002
Page 88
TMP89FM42
8. I/O Ports
Table 8-1 List of I/O Ports
Port name Port P0 Pin name P03 to P00 (Note) P13 to P10 Number of pins 4 (Note) 4 Input/output Input/output Secondary functions Also used as the high-frequency oscillator connection pin and the low-frequency oscillator connection pin Also used as the external reset input, the external interrupt input and the STOP mode release signal input Also used as the UART input/output, the serial interface input/output and the serial bus interface input/output Also used as the analog input and the key-on wakeup input Also used as the timer counter input/output, the divider output and the external interrupt input Also used as the timer counter input/output Also used as the UART input/output Also used as the UART input/output and the serial interface input/output
Port P1
Input/output
Port P2 Port P4 Port P7 Port P8 Port P9 Port PB
P27 to P20 P47 to P40 P77 to P70 P81 to P80 P91 to P90 PB7 to PB4
8 8 8 2 2 4
Input/output Input/output Input/output Input/output Input/output Input/output
Note: P00 and P01 pins can not be used for the I/O port, because they should be connected with the high frequency OSC input.
Each output port contains a latch, which holds the output data. No input port has a latch, so the external input data should be externally held until the input data is read from outside or reading should be performed several times before processing. Figure 8-1 shows input/output timing examples. External data is read from an I/O port in the read cycle during execution of the read instruction. This timing cannot be recognized from outside, so that transient input such as chattering must be processed by the program. Data is output to an I/O port in the next cycle of the write cycle during execution of the write instruction.
Fetch cycle System clock Example: LD A, (x) Fetch cycle Read cycle
Instruction execution cycle Internal read signal Data input
(a) Input timing
Fetch cycle System clock
Fetch cycle
Write cycle
Instruction execution cycle Internal write signal Data input
Example: LD (x), A
(b) Input timing
Figure 8-1 Input/Output Timing (Example)
Note: The positions of the read and write cycles may vary, depending on the instruction.
RA005
Page 89
8. I/O Ports
8.1 I/O Port Control Registers TMP89FM42
8.1 I/O Port Control Registers
The following control registers are used for I/O ports. (The port number is indicated in place of x.) Registers that can be set vary depending on the port. For details, refer to the description of each port. * PxDR register This is the register for setting output data. When a port is set to the "output mode", the value specified at PxDR is output from the port. * PxPRD register This is the register for reading input data. When a port is set to the "input mode", the current port input status can be read by reading PxPRD. * PxCR register This register switches a port between input and output. A port can be switched between the "input mode" and the "output mode". * PxFC register This register enables the secondary function output of each port. The secondary function output of each port can be enabled or disabled. * PxOUTCR register This register switches the port output between the C-MOS output and the open drain output. * PxPU register This register determines whether or not the built-in pull-up resistor is connected when a port is used in the input mode or as the open drain output.
RA005
Page 90
TMP89FM42
8.2 List of I/O Port Settings
For the setting methods for individual I/O ports, refer to the following table. Table 8-2
Port name
List of I/O Port Settings
Register set value Pin name Function PxCR PxOUTCR PxFC 0 0 Without register 1 Without register 1 Other required settings
Port P0 P03 to P00
Port input Port output P03 P02 P01 P00 XTOUT XTIN XOUT XIN Port input P13 to P11 Port output P10 P10 P13 P12 P11 P11 P10 Port input Port output INT1 input
INT0 input INT5 input STOP input RESET input
0 1 * * * * 0 1 0 1 0 0 0 0 * 0 1 0 1 1 0 1 1 0 * * * * Without register Without register Without register Without register
Port P1
Note 1 Note 1 Without register
Note 1 * 0 * 1 1 * 1 1 * SERSEL="01" SERSEL="01" SERSEL="*0" SERSEL="01" SERSEL="*0" SERSEL="01" SERSEL="10" SERSEL="0" SERSEL="10" SERSEL="0" SERSEL="0*" SERSEL="0" UATCNG="0" SERSEL="0*" SERSEL="0" UATCNG="1" SERSEL="10" SERSEL="0"
Port P2 P27 to P20
Port input Port output SCLK0 input P25 SCLK0 output SCL0 input/output P24 SI input SDA0 input/output P23 SO output SCLK0 input P22 SCLK0 output
*
1
*
1
RXD0 input
0
*
*
P21
TXD0 output
1
*
1
SI0 input
0
*
*
RA005
Page 91
8. I/O Ports
8.2 List of I/O Port Settings TMP89FM42
Table 8-2
Port name
List of I/O Port Settings
Register set value Pin name Function PxCR PxOUTCR PxFC Other required settings SERSEL="0*" SERSEL="0" UATCNG="0" SERSEL="0*" SERSEL="0" UATCNG="1" SERSEL="10" SERSEL="0"
TXD0 output
1
*
1
P20
RXD0 input
0
*
*
SO0 output Port P4 Port input Port output P47 to P40 AIN7 to AIN0 KWI7 to KWI4 KWI3 to KWI0 Port P7 P77 to P70 Port output P77 INT4 input Port input
1 0 1 0 * * 0 1 0
*
1 * 0
Without register
1 * * * 0 Without register Without register Without register KWUCR1 KWUCR0
P76
INT3 input
0
P75 P74
INT2 input
DVO output
0 1 0 1 0 1 0 1 0 1
TCA1 input P73
PPGA1 output
Without register
1 * 1 * 1 * 1 * 1 SERSEL="00"
TCA0 input P72
PPGA0 output
TC01 input P71
PPG01 / PWM01 output
TC00 input P70
PPG00 / PWM00 output
RA005
Page 92
TMP89FM42
Table 8-2
Port name
List of I/O Port Settings
Register set value Pin name Function PxCR PxOUTCR PxFC * 0 Without register * 1 * 1 * * * * * * * * * * 0 0 1 1 0 * 0 * SERSEL="10" SERSEL="1" SERSEL="10" SERSEL="1" SERSEL="0*" SERSEL="1" UATCNG="0" SERSEL="0*" SERSEL="1" UATCNG="1" SERSEL="10" SERSEL="1" SERSEL="0*" SERSEL="1" UATCNG="0" SERSEL="0*" SERSEL="1" UATCNG="1" SERSEL="10" SERSEL="1" UATCNG="0" UATCNG="1" UATCNG="0" UATCNG="1" Other required settings
Port P8 P81 to P80
Port input Port output TC03 input P81
PPG03 / PWM03 output
0 1 0 1 0 1 0 1 0 1 1 0 0 1 0
TC02 input P80
PPG02 / PWM02 output
Port P9 P92 to P90
Port input Port output RXD1 input P91 TXD1 output TXD1 output P90 RXD1 input
Port PB PB7 to PB4
Port input Port output SCLK0 input PB6 SCLK0 output
1
*
1
RXD0 input
0
*
*
PB5
TXD0 output
1
*
1
SI0 input
0
*
*
TXD0 output
1
*
1
PB4
RXD0 input
0
*
*
SO0 output
1
*
1
Note 1: After the power is turned on, pin P10 serves as an external reset input. To use pin P10 as a port, refer to "How to use the external reset input pin as a port". Note 2: About SERSEL, please refer to "8.4 Serial Interface Selecting Function". Note 3: The symbol and numeric characters in the table have the following meanings:
Symbol and numeric characters 0 1 * Without register
Meaning
Set "0". Set "1". Don't care (Operation is the same whether "1" or "0" is selected.) There is no register that corresponds to the bit.
RA005
Page 93
8. I/O Ports
8.3 I/O Port Registers TMP89FM42
8.3 I/O Port Registers
8.3.1 Port P0 (P03 to P00)
Port P0 is a 4-bit input/output port that can be set to input or output for each bit individually, and it is also used as the high-frequency oscillation connection pin and the low-frequency oscillation connection pin. Port P0 contains a programmable pull-up resistor on the VDD side. This pull-up resistor can be used when the port is used in the input mode. Table 8-3 Port P0
Secondary function P03 XTOUT P02 XTIN P01 XOUT P00 XIN
VDD Pull-up control (for each bit) P0PU0 write Input/output control (for each bit) P0CR0 write Function control (for each bit) P0FC0 write Output latch (for each bit) Internal data bus P0DR0 write P0PRD0 read VDD Pull-up control (for each bit) P0PU1 write Input/output control (for each bit) P0CR1 write System clock reset (internal factor reset) VDD Ro P01 (XOUT) Output latch (for each bit) P0DR1 write P0PRD1 read SYSCR2 SYSCR1 SYSCR1 Reset signal Note1 : R = 100 (typ.) Note2 : Rf = 1.2M (typ.) Note3 : Ro = 0.5k (typ.) Note4 : RIN3 = 50k (typ.) R Programmable pull-up resistor RIN3 Rf R VDD Programmable pull-up resistor RIN3
P00 (XIN)
Figure 8-2 Port P0 (P00, P01)
RA005
Page 94
TMP89FM42
VDD Pull-up control (for each bit) P0PU2 write Input/output control (for each bit) P0CR2 write Function control (for each bit) P0FC2 write Output latch (for each bit) Internal data bus P0DR2 write P0PRD2 read VDD Pull-up control (for each bit) P0PU3 write Input/output control (for each bit) P0CR3 write VDD Ro P03 (XTOUT) Output latch (for each bit) P0DR3 write P0PRD3 read SYSCR2 SYSCR1 SYSCR1 Reset signal Note1 : R = 100 (typ.) Note2 : Rf = 6M (typ.) Note3 : Ro = 220k (typ.) Note4 : RIN3 = 50k (typ.) R Programmable pull-up resistor RIN3 Rf R VDD Programmable pull-up resistor RIN3
P02 (XTIN)
Figure 8-3 Port P0 (P02, P03)
RA005
Page 95
8. I/O Ports
8.3 I/O Port Registers TMP89FM42
Port P0 output latch
P0DR (0x0000) 7 Bit Symbol Read/Write After reset 0: Function 1: Outputs H level when the output mode is selected. R 0 6 R 0 5 R 0 4 R 0 3 P03 R/W 0 2 P02 R/W 0 1 P01 R/W 0 0 P00 R/W 0
Outputs L level when the output mode is selected.
Port P0 input/output control
P0CR (0x0F1A) 7 Bit Symbol Read/Write After reset 0: Function 1: Output mode (port output) R 0 6 R 0 5 R 0 4 R 0 3 P0CR3 R/W 0 2 P0CR2 R/W 0 1 P0CR1 R/W 0 0 P0CR0 R/W 0
Input mode (port input)
Note: P0CR1 and P0CR0 must be clear to "0".
Port P0 function control
P0FC (0x0F34) 7 Bit Symbol Read/Write After reset 0: Function 1: R 0 6 R 0 5 R 0 4 R 0 3 R 0 2 P0FC2 R/W 0 Port function XTIN (I) 1 R 0 0 P0FC0 R/W 1 Port function XIN (I)
Note 1: When SYSCR2 is "1", setting P0FC0 to "0" generates a system clock (internal factor) reset. Normally, ports P00 or P01 are not used as ports, so P0FC0 must be set to "1". Note 2: Symbol "I" means secondary function input
Port P0 built-in pull-up resistor control
P0PU (0x0F27) 7 Bit Symbol Read/Write After reset 0: Function 1: R 0 6 R 0 5 R 0 4 R 0 3 P0PU2 R/W 0 2 P0PU2 R/W 0 1 P0PU1 R/W 0 0 P0PU0 R/W 0
The built-in pull-up resistor is not connected. The built-in pull-up resistor is connected. (The resistor is connected in the input mode only. Under any other conditions, setting to "1" does not make the resistor connected.)
Port P0 input data
P0PRD (0x000D) 7 Bit Symbol Read/Write After reset Function R 0 6 R 0 5 R 0 4 R 0 3 P0PRD3 R * 2 P0PRD2 R * 1 P0PRD1 R * 0 P0PRD0 R *
If the port is in the input mode, the contents of the port are read. If not, "0" is read.
RA005
Page 96
TMP89FM42
Table 8-4 P0PRD Read Value (P00 to P01)
Set condition P0PRDi read value P0FC0 * 1 0 P0CRi 1 * 0 "0" "0" Contents of port
Note 1: * : Don't care Note 2: i = 0, 1
Table 8-5 P0PRD Read Value (P02 to P03)
Set condition P0PRDj read value P0FC2 * 1 0 P0CRj 1 * 0 "0" "0" Contents of port
Note 1: * : Don't care Note 2: j = 2, 3
RA005
Page 97
8. I/O Ports
8.3 I/O Port Registers TMP89FM42
8.3.2
Port P1 (P13 to P10)
Port P1 is a 4-bit input/output port that can be set to input or output for each bit individually, and is also used as the external interrupt input, the STOP mode release signal input and the external reset input. Port P1 contains a programmable pull-up resistor on the VDD side. This pull-up resistor can be used when the port is used in the input mode. After reset, pin P10 serves as the external reset input. To use pin P10 as a port, refer to "How to use external reset input pin as a port". Table 8-6 Port P1
Secondary function P13 INT1 P12
INT0
P11
INT5 STOP
P10
RESET
RA005
Page 98
TMP89FM42
VDD
VDD Pull-up control (for each bit) P1PU write Internal data bus Input/output control (for each bit) P1CR write Output latch (for each bit) P1DR write P1PRD read SYSCR3 SYSCR4
Power-on reset signal Reset 1 Reset 2 Low-voltage detection reset 1 signal Low-voltage detection reset 2 signal Watchdog timer reset signal System clock reset signal Trimming data reset signal Flash standby reset signal
Reset pull-up resistor Programmable pull-up resistor VDD RIN3 RIN2
P10
R
EN B2H write
Note1 : R = 100 (typ.) Note2 : RIN2 = 220k (typ.) Note3 : RIN3 = 50k (typ.)
VDD Pull-up control (for each bit) P1PU write Internal data bus Input/output control (for each bit) P1CR write Output latch (for each bit) P1DR write P1PRD read Interrupt STOP control INT0, INT1, INT5, STOP SYSCR1 SYSCR1 Reset signal Reset signal In case of P11 In case of P12 and P13 R VDD Programmable pull-up resistor RIN3
P1i
Peripheral functions
Note1 : R = 100 (typ.) Note2 : RIN3 = 50k (typ.) Note3 : i = 1 ~ 3
Figure 8-4 Port P1
RA005
Page 99
8. I/O Ports
8.3 I/O Port Registers TMP89FM42
Port P1 output latch
P1DR (0x0001) 7 Bit Symbol Read/Write After reset 0: Function 1: Outputs H level when the output mode is selected. R 0 6 R 0 5 R 0 4 R 0 3 P13 R/W 0 2 P12 R/W 0 1 P11 R/W 0 0 P10 R/W 0
Outputs L level when the output mode is selected.
Port P1 input/output control
P1CR (0x0F1B) 7 Bit Symbol Read/Write After reset R 0 6 R 0 5 R 0 4 R 0 3 P1CR3 R/W 0 2 P1CR2 R/W 0 1 P1CR1 R/W 0 0 P1CR0 R/W 0
Input mode (port input) 0: Function 1: INT1 (I)
INT0 (I) INT5 (I) STOP (I)
-
Output mode (port output)
Note: Symbol "I" means secondary function input
Port P1 built-in pull-up resistor control
P1PU (0x0F28) 7 Bit Symbol Read/Write After reset 0: Function 1: R 0 6 R 0 5 R 0 4 R 0 3 P1PU4 R/W 0 2 P1PU2 R/W 0 1 P1PU1 R/W 0 0 P1PU0 R/W 0
The built-in pull-up resistor is not connected. The built-in pull-up resistor is connected. (The resistor is connected only when the port is used in the input mode or as the open drain output. Under any other conditions, setting to "1" does not make the resistor connected.)
Port P1 input data
P1PRD (0x000E) 7 Bit Symbol Read/Write After reset Function R 0 6 R 0 5 R 0 4 R 0 3 P1PRD3 R * 2 P1PRD2 R * 1 P1PRD1 R * 0 P1PRD0 R *
If the port is in the input mode, the contents of the port are read. If not, "0" is read.
Table 8-7 P1PRD Read Value
Set condition P1CRi 0 1 Contents of port "0"
P1PRDi read value
Note 1: * : Don't care Note 2: i = 0 to 3
RA005
Page 100
TMP89FM42
8.3.3
Port P2 (P27 to P20)
Port P2 is an 8-bit input/output port that can be set to input or output for each bit individually, and it is also used as the serial bus interface input/output, the serial interface input/output, the UART input/output and the on-chip debug function. The output circuit has the P-channel output control function and either the sink open drain output or the CMOS output can be selected. Port P2 contains a programmable pull-up resistor on the VDD side. This pull-up resistor can be used when the port is used in the input mode or as a sink open drain output. When this port is used as the serial bus interface, the serial interface or the UART, setting for serial interface selecting function is also needed. For details, refer to "8.4 Serial Interface Selecting Function". For the on-chip debug function, refer to the chapter of "On-chip Debug Function (OCD)". Table 8-8 Port P2
P27 Secondary function P26 P25 SCLK0 P24 SI0 SCL0 P23 SO0 SDA0 P22 SCLK0 P21 SI0 RXD0 TXD0 OCDIO P20 SO0 TXD0 RXD0 OCDCK
RA005
Page 101
8. I/O Ports
8.3 I/O Port Registers TMP89FM42
VDD Pull-up control (for each bit) P2PU write Output control (for each bit) P2OUTCR write Programmable pull-up resistor RIN3
Internal data bus
Input/output control (for each bit) P2CR write Function control (for each bit) P2FC write Output latch (for each bit) 0S 1 P2DR write SCLK0, SO0, TXD0
Functions enclosed by the dotted line are for P20, P21,P22 and P25 only.
VDD
P2i
Peripheral functions
R
SIO0 UART0
P2PRD read
SCLK0, SI0, RXD0
SYSCR1 SYSCR1 Reset signal
Note1 : R = 100 (typ.) Note2 : RIN3 = 50k (typ.) Note3 : i = 0 to 2, 5 to 7
Input/output control (for each bit) P2CR write
Internal data bus
Function control (for each bit) P2FC write Output latch (for each bit) P2DR write R SCL0, SDA0, SO0 0S 1
P2j
Peripheral functions
SIO0 I2C0
P2PRD read SCL0, SDA0, SI0 SYSCR1 SYSCR1 Reset signal
Note1 : R = 100 (typ.) Note2 : j = 3, 4
Figure 8-5 Port P2
RA005
Page 102
TMP89FM42
Port P2 output latch
P2DR (0x0002) 7 Bit Symbol Read/Write After reset 0: Function 1: P27 R/W 0 6 P26 R/W 0 5 P25 R/W 0 4 P24 R/W 0 3 P23 R/W 0 2 P22 R/W 0 1 P21 R/W 0 0 P20 R/W 0
Outputs L level when the output mode is selected. Outputs H level when the output mode is selected. (Serves as Hi-Z or pull-up depending on settings of P2OUTCR and P2PU.)
Port P2 input/output control
P2CR (0x0F1C) 7 Bit Symbol Read/Write After reset P2CR7 R/W 0 6 P2CR6 R/W 0 5 P2CR5 R/W 0 4 P2CR4 R/W 0 3 P2CR3 R/W 0 2 P2CR2 R/W 0 1 P2CR1 R/W 0 0 P2CR0 R/W 0
Input mode (port input) 0: Function Output mode (port output) 1: SCLK0 (O) SCL0 (I/O) SDA0 (I/O) SO (O) SCLK0 (O) TXD0(O) TXD0 (O) SO0 (O) SCLK0 (I) SI0 (I) SCLK0 (I) RXD0 (I) SI0 (I) RXD0 (I)
Note: Symbol "I" means secondary function input. Symbol "O" means secondary function output. Symbol "I/O" means secondary function input/output
Port P2 function control
P2FC (0x0F36) 7 Bit Symbol Read/Write After reset 0: Function 1: R 0 6 R 0 5 P2FC5 R/W 0 Port function SCLK0 (O) SCL0 (I/O) SDA0 (I/O) SO0 (O) SCLK0 (O) TXD0 (O) TXD0 (O) SO0 (O) 4 P2FC4 R/W 0 3 P2FC3 R/W 0 2 P2FC2 R/W 0 1 P2FC1 R/W 0 0 P2FC0 R/W 0
Port P2 output control
P2OUTCR (0x0F43) 7 Bit Symbol Read/Write After reset 0: Function 1: Open drain output Open drain output P2OUT7 R/W 0 C-MOS output 6 P2OUT6 R/W 0 5 P2OUT5 R/W 0 4 R 0 3 R 0 2 P2OUT2 R/W 0 C-MOS output 1 P2OUT1 R/W 0 0 P2OUT0 R/W 0
RA005
Page 103
8. I/O Ports
8.3 I/O Port Registers TMP89FM42
Port P2 built-in pull-up resistor control
P2PU (0x0F29) 7 Bit Symbol Read/Write After reset 0: P2PU7 R/W 0 6 P2PU6 R/W 0 5 P2PU5 R/W 0 4 R 0 3 R 0 2 P2PU2 R/W 0 1 P2PU1 R/W 0 0 P2PU0 R/W 0
The built-in pull-up resistor is not connected. The built-in pull-up resistor is connected. (The resistor is connected only when the port is used in the input mode or as the open drain output. Under any other conditions, setting to "1" does not make the resistor connected.)
The built-in pull-up resistor is not connected. The built-in pull-up resistor is connected. (The resistor is connected only when the port is used in the input mode or as the open drain output. Under any other conditions, setting to "1" does not make the resistor connected.)
Function 1:
Port P2 input data
P2PRD (0x000F) 7 Bit Symbol Read/Write After reset P2PRD7 R * 6 P2PRD6 R * 5 P2PRD5 R * 4 P2PRD4 R * 3 P2PRD3 R * 2 P2PRD2 R * 1 P2PRD1 R * 0 P2PRD0 R *
Function
If the port is used in the input mode or as the open drain output, the contents of the port are read. If not, "0" is read.
The contents of the port are read without condition.
If the port is used in the input mode or as the open drain output, the contents of the port are read. If not, "0" is read.
Table 8-9 P2PRD Read Value (P20 to P22, P25 to P27)
Set condition P2PRDi read value P2CRi 0 1 1 P2OUTCRi * 0 1 Contents of port "0" Contents of port
Note: * : Don't care Note: i = 0 to 2, 5 to 7
RA005
Page 104
TMP89FM42
8.3.4
Port P4 (P47 to P40)
Port P4 is an 8-bit input/output port that can be set to input or output for each bit individually, and it is also used as the analog input and the key-on wakeup input. Port P4 contains a programmable pull-up resistor on the VDD side. This pull-up resistor can be used when the port is used in the input mode. Table 8-10 Port P4
P47 Secondary function AIN7 KWI7 P46 AIN6 KWI6 P45 AIN5 KWI5 P44 AIN4 KWI4 P43 AIN3 KWI3 P42 AIN2 KWI2 P41 AIN1 KWI1 P40 AIN0 KWI0
SYSCR1 SYSCR1 VDD Pull-up control (for each bit) P4PU write Input/output control (for each bit) P4CR write Function control (for each bit) P4FC write Output latch (for each bit) Peripheral functions P4DR write KWIi enable signal Key-on wakeup R VDD Programmable pull-up resistor RIN3
Internal data bus
P4i
P4PRD read
KWIi Reset signal
Note1 : R = 100 (typ.) Note2 : RIN3 = 50k (typ.) Note3 : i = 0 to 7
AINi enable signal AD ADCCR1
AINi
Figure 8-6 Port P4
RA005
Page 105
8. I/O Ports
8.3 I/O Port Registers TMP89FM42
Port P4 output latch
P4DR (0x0004) 7 Bit Symbol Read/Write After reset 0: Function 1: Outputs H level when the output mode is selected. P47 R/W 0 6 P46 R/W 0 5 P45 R/W 0 4 P44 R/W 0 3 P43 R/W 0 2 P42 R/W 0 1 P41 R/W 0 0 P40 R/W 0
Outputs L level when the output mode is selected.
Port P4 input/output control
P4CR (0x0F1E) 7 Bit Symbol Read/Write After reset 0: Function 1: AIN7 (I) AIN6 (I) AIN5 (I) AIN4 (I) AIN3 (I) AIN2 (I) AIN1 (I) AIN0 (I) Output mode (port output) P4CR7 R/W 0 6 P4CR6 R/W 0 5 P4CR5 R/W 0 4 P4CR4 R/W 0 3 P4CR3 R/W 0 2 P4CR2 R/W 0 1 P4CR1 R/W 0 0 P4CR0 R/W 0
Input mode (port input)
Note 1: Symbol "I" means secondary function input. Note 2: When the key-on wakeup input (KWIi) is enabled (KWUCRm="1"), there is no need to set P4CRi. (i=7 to 0, m=1 to 0, n=3 to 0)
Port P4 function control
P4FC (0x0F38) 7 Bit Symbol Read/Write After reset 0: Function 1: AIN7 (I) AIN6 (I) AIN5 (I) AIN4 (I) AIN3 (I) AIN2 (I) AIN1 (I) AIN0 (I) P4FC7 R/W 0 Port function 6 P4FC6 R/W 0 5 P4FC5 R/W 0 4 P4FC4 R/W 0 3 P4FC3 R/W 0 2 P4FC2 R/W 0 1 P4FC1 R/W 0 0 P4FC0 R/W 0
Note 1: When the key-on wakeup input (KWIi) is enabled, there is no need to set P4FCi.
Port P4 built-in pull-up resistor control
P4PU (0x0F2B) 7 Bit Symbol Read/Write After reset 0: Function 1: P4PU7 R/W 0 6 P4PU6 R/W 0 5 P4PU5 R/W 0 4 P4PU4 R/W 0 3 P4PU3 R/W 0 2 P4PU2 R/W 0 1 P4PU1 R/W 0 0 P4PU0 R/W 0
The built-in pull-up resistor is not connected. The built-in pull-up resistor is connected. (The resistor is connected only when the key-on wakeup input (KWIi) is enabled or the port is used in the input mode (P4FCi="0" and P4CRi="0"). Under any other conditions, setting to "1" does not make the resistor connected.)
Port P4 input data
P4PRD (0x0011) 7 Bit Symbol Read/Write After reset Function P4PRD7 R * 6 P4PRD6 R * 5 P4PRD5 R * 4 P4PRD4 R * 3 P4PRD3 R * 2 P4PRD2 R * 1 P4PRD1 R * 0 P4PRD0 R *
If the port is in the input mode, the contents of the port are read. If not, "0" is read.
RA005
Page 106
TMP89FM42
Table 8-11 P4PRD Read Value
Set condition P4PRDi read value P4CRi 0 * 1 P4FCi 0 1 * Contents of port "0" "0"
Note 1: * : Don't care Note 2: i = 0 to 7
RA005
Page 107
8. I/O Ports
8.3 I/O Port Registers TMP89FM42
8.3.5
Port P7 (P77 to P70)
Port P7 is an 8-bit input/output port that can be set to input or output for each bit individually, and it is also used as the external interrupt input, the divider output and the timer counter input/output. Table 8-12 Port P7
P77 Secondary function INT4 P76 INT3 P75 INT2 P74
DVO
P73
PPGA1
P72
PPGA0
P71
PPG01 PWM01
P70
PPG00 PWM00
TCA1
TCA0
TC01
TC00
Input/output control (for each bit) P7CR write
Internal data bus
Function control (for each bit) P7FC write Output latch (for each bit) P7DR write
DVO, PPGA1, PPGA0, PPG01, PPG00, PWM01, PWM00
VDD
P7i 0S 1
Functions enclosed by the dotted line are for P74 to P70 only.
Peripheral functions Divider output External interrupt
(Note3)
R
P7PRD read TCA0 TCA1 TC00 TC01
INT4, INT3, INT2, TCA1, TCA0, TC01, TC00
SYSCR1 SYSCR1 Reset signal
Note1 : R = 100 (typ.) Note2 : i = 0 to 7 Note3 : Nch large current (Only P70 to P73)
Figure 8-7 Port P7
RA005
Page 108
TMP89FM42
Port P7 output latch
P7DR (0x0007) 7 Bit Symbol Read/Write After reset 0: Function 1: Outputs H level when the output mode is selected P77 R/W 0 6 P76 R/W 0 5 P75 R/W 0 4 P74 R/W 0 3 P73 R/W 0 2 P72 R/W 0 1 P71 R/W 0 0 P70 R/W 0
Outputs L level when the output mode is selected
Port P7 input/output control
P7CR (0x0F21) 7 Bit Symbol Read/Write After reset 0: INT4 (I) Function 1: INT3 (I) INT2 (I) TCA1 (I) TCA0 (I) TC01 (I) TC00 (I) Output mode (port output) DVO (O) PPGA1 (O) PPGA0 (O) PPG01 (O) PWM01 (O) PPG00 (O) PWM00 (O)
6 P7CR6 R/W 0
5 P7CR5 R/W 0
4 P7CR4 R/W 0
3 P7CR3 R/W 0
2 P7CR2 R/W 0
1 P7CR1 R/W 0
0 P7CR0 R/W 0
P7CR7 R/W 0
Input mode (port input)
Note: Symbol "I" means secondary function input. Symbol "O" means secondary function output.
Port P7 function control
P7FC (0x0F3B) 7 Bit Symbol Read/Write After reset 0: Function 1:
DVO (O) PPGA1 (O)
6 R 0
5 R 0
4 P7FC3 R/W 0
3 P7FC3 R/W 0
2 P7FC2 R/W 0 Port function
PPGA0 (O)
1 P7FC1 R/W 0
0 P7FC0 R/W 0
R 0
PPG01 (O) PWM01 (O)
PPG00 (O) PWM00 (O)
Port P7 input data
P7PRD (0x0014) 7 Bit Symbol Read/Write After reset Function P7PRD7 R * 6 P7PRD6 R * 5 P7PRD5 R * 4 P7PRD4 R * 3 P7PRD3 R * 2 P7PRD2 R * 1 P7PRD1 R * 0 P7PRD0 R *
If the port is used in the input mode, the contents of the port are read. If not, "0" is read.
Table 8-13 P7PRD Read Value
Set condition P7PRDi read value P7CRi 0 1 Contents of port "0"
Note 1: * : Don't care Note 2: i = 0 to 7
RA005
Page 109
8. I/O Ports
8.3 I/O Port Registers TMP89FM42
8.3.6
Port P8 (P81 to P80)
Port P8 is a 2-bit input/output port that can be set to input or output for each bit individually, and it is also used as the timer counter input/output. Table 8-14 Port P8
P81 Secondary function PPG03 PWM03
P80
PPG02 PWM02
TC03
TC02
Input/output control (for each bit) P8CR write
Internal data bus
Function control (for each bit) P8FC write Output latch (for each bit) P8DR write 0S 1
Functions enclosed by the dotted line are for P81 and P80 only.
VDD
P8i
Peripheral functions
R
TC03 TC02
PPG03, PPG02, PWM03, PWM02
P8PRD read TC03, TC02 SYSCR1 SYSCR1 Reset signal
Note1 : R = 100 (typ.)
Note2 : i = 0 to 1
Figure 8-8 Port P8
RA005
Page 110
TMP89FM42
Port P8 output latch
P8DR (0x0008) 7 Bit Symbol Read/Write After reset 0: Function 1: Outputs H level when the output mode is selected. R 0 6 R 0 5 R 0 4 R 0 3 R 0 2 R 0 1 P81 R/W 0 0 P80 R/W 0
Outputs L level when the output mode is selected.
Port P8 input/output control
P8CR (0x0F22) 7 Bit Symbol Read/Write After reset 0: TC03 (I) Function 1: TC02 (I) Output mode (port output)
PPG03 (O) PWM03 (O) PPG02 (O) PWM02 (O)
6 R 0
5 R 0
4 R 0
3 R 0
2 R 0
1 P8CR1 R/W 0
0 P8CR0 R/W 0
R 0
Input mode (port input)
Note: Symbol "I" means secondary function input. Symbol "O" means secondary function output.
Port P8 function control
P8FC (0x0F3C) 7 Bit Symbol Read/Write After reset 0: Function 1: R 0 6 R 0 5 R 0 4 R 0 3 R 0 2 R 0 1 P8FC1 R/W 0 Port function
PPG03 (O) PWM03 (O) PPG02 (O) PWM02 (O)
0 P8FC0 R/W 0
Port P8 input data
P8PRD (0x0015) 7 Bit Symbol Read/Write After reset R 0 6 R 0 5 R 0 4 R 0 3 R 0 2 R 0 1 P8PRD1 R * 0 P8PRD0 R *
Function
If the port is used in the input mode, the contents of the port are read. If not, "0" is read.
Table 8-15 P8PRD Read Value
Set condition P8PRDi read value P8CRi 0 1 Contents of port "0"
Note 1: * : Don't care
RA005
Page 111
8. I/O Ports
8.3 I/O Port Registers TMP89FM42
Note 2: i = 0 to 1
RA005
Page 112
TMP89FM42
8.3.7
Port P9 (P91 to P90)
Port P9 is a 2-bit input/output port that can be set to input or output for each bit individually, and it is also used as the UART. The output circuit has the P-channel output control function and either the sink open drain output or the CMOS output can be selected. Port P9 contains a programmable pull-up resistor on the VDD side. This pull-up resistor can be used when the port is used in the input mode or as a sink open drain output. When this port is used as the UART, setting for the serial interface selecting function is also needed. For details, refer to "8.4 Serial Interface Selecting Function". Table 8-16 Port P9
P91 Secondary function RXD1 TXD1 P90 TXD1 RXD1
VDD Pull-up control (for each bit) P9PU write Output control (for each bit) P9OUTCR write Internal data bus Input/output control (for each bit) P9CR write Function control (for each bit) P9FC write Output latch (for each bit) P9DR write Peripheral functions R TXD1 0S 1 VDD Programmable pull-up resistor RIN3
P9i
UART1
P9PRD read RXD1 SYSCR1 SYSCR1 Reset signal
Note1 : R = 100 (typ.) Note2 : RIN3 = 50k (typ.) Note3 : i = 0 to 1
Figure 8-9 Port P9
RA005
Page 113
8. I/O Ports
8.3 I/O Port Registers TMP89FM42
Port P9 output latch
P9DR (0x0009) 7 Bit Symbol Read/Write After reset 0: R 0 6 R 0 5 R 0 4 R 0 3 R 0 2 R 0 1 P91 R/W 0 0 P90 R/W 0
Outputs L level when the output mode is selected. Outputs H level when the output mode is selected. (Serves as Hi-Z or pull-up depending on settings of P9OUTCR and P9PU.)
Function 1:
Port P9 input/output control
P9CR (0x0F23) 7 Bit Symbol Read/Write After reset 0: RXD1 (I) Function Output mode (port output) 1: TXD1 (O) TXD1 (O) RXD1 (I) R 0 6 R 0 5 R 0 4 R 0 3 R 0 2 R 0 1 P9CR1 R/W 0 0 P9CR0 R/W 0
Input mode (port input)
Note: Symbol "I" means secondary function input. Symbol "O" means secondary function output.
Port P9 function control
P9FC (0x0F3D) 7 Bit Symbol Read/Write After reset 0: Function 1: TXD1 (O) TXD1 (O) R 0 6 R 0 5 R 0 4 R 0 3 R 0 2 R 0 1 P9FC1 R/W 0 Port function 0 P9FC0 R/W 0
Port P9 output control
P9OUTCR (0x0F4A) 7 Bit Symbol Read/Write After reset 0: Function 1: Open drain output R 0 6 R 0 5 R 0 4 R 0 3 R 0 2 R 0 1 P9OUT1 R/W 0 C-MOS output 0 P9OUT0 R/W 0
Port P9 built-in pull-up resistor control
P9PU (0x0F30) 7 Bit Symbol Read/Write After reset 0: Function 1: R 0 6 R 0 5 R 0 4 R 0 3 R 0 2 R 0 1 P9PU1 R/W 0 0 P9PU0 R/W 0
The built-in pull-up resistor is not connected. Note 1
Note 1: The built-in pull-up resistor is connected. (The resistor is connected only when the port is used in the input mode or as the open drain output. Under any other conditions, setting to "1" does not make the resistor connected.)
RA005
Page 114
TMP89FM42
Port P9 input data
P9PRD (0x0016) 7 Bit Symbol Read/Write After reset R 0 6 R 0 5 R 0 4 R 0 3 R 0 2 R 0 1 P9PRD1 R * 0 P9PRD0 R *
Function
If the port is used in the input mode or as the sink open drain output, the contents of the port are read. If not, "0" is read.
Table 8-17 P9PRD Read Value
Set condition P9PRDi read value P9CRi 0 1 1 P9OUTCRi * 0 1 Contents of port "0" Contents of port
Note 1: * : Don't care Note 2: i = 0 to 1
RA005
Page 115
8. I/O Ports
8.3 I/O Port Registers TMP89FM42
8.3.8
Port PB (PB7 to PB4)
Port PB is an 4-bit input/output port that can be set to input or output for each bit individually, and it is also used as the serial interface input/output and the UART input/output. The output circuit has the P-channel output control function and either the sink open drain output or the CMOS output can be selected. When this port is used as the serial interface or the UART, setting for serial interface selecting function is also needed. For details, refer to "8.4 Serial Interface Selecting Function". Table 8-18 Port PB
PB7 Secondary function PB6 SCLK0 PB5 SI0 RXD0 TXD0 PB4 SO0 TXD0 RXD0 -
Output control (for each bit) PBOUTCR write Internal data bus Input/output control (for each bit) PBCR write Function control (for each bit) PBFC write Output latch (for each bit) Peripheral functions PBDR write 0S 1
Functions enclosed by the dotted line are for PB6 to PB4 only.
PBi
(Note2)
SCLK0, SO0, TXD0 SIO0 UART0
PBPRD read
R
SCLK0, SI0, RXD0
SYSCR1 SYSCR1 Reset signal
Note1 : R = 100 (typ.) Note2 : Nch large current Note3 : i = 4 to 7
Figure 8-10 Port PB
RA005
Page 116
TMP89FM42
Port PB output latch
PBDR (0x000B) 7 Bit Symbol Read/Write After reset 0: Function 1: Outputs H level when the output mode is selected. PB7 R/W 0 6 PB6 R/W 0 5 PB5 R/W 0 4 PB4 R/W 0 3 R 0 2 R 0 1 R 0 0 R 0
Outputs L level when the output mode is selected.
Port PB input/output control
PBCR (0x0F25) 7 Bit Symbol Read/Write After reset 0: Function 1: Output mode (port output) PBCR7 R/W 0 6 PBCR6 R/W 0 5 PBCR5 R/W 0 4 PBCR4 R/W 0 3 R 0 2 R 0 1 R 0 0 R 0
Input mode (port input)
Port PB function control
PBFC (0x0F3F) 7 Bit Symbol Read/Write After reset 0: Function 1: R 0 6 PBFC6 R/W 0 Port function SCLK0 (O) TXD0 (O) TXD0 (O) SO0 (O) 5 PBFC5 R/W 0 4 PBFC4 R/W 0 3 R 0 2 R 0 1 R 0 0 R 0
Port PB output control
PBOUTCR (0x0F4C) 7 Bit Symbol Read/Write After reset 0: Function 1: Open drain output PBOUT7 R/W 0 C-MOS output 6 PBOUT6 R/W 0 5 PBOUT5 R/W 0 4 PBOUT4 R/W 0 3 R 0 2 R 0 1 R 0 0 R 0
Port PB input data
PBPRD (0x0018) 7 Bit Symbol Read/Write After reset PBPRD7 R * 6 PBPRD6 R * 5 PBPRD5 R * 4 PBPRD4 R * R * R * R * R * 3 2 1 0
Function
If the port is used in the input mode or as the open drain output, the contents of the port are read. If not, "0" is read.
RA005
Page 117
8. I/O Ports
8.3 I/O Port Registers TMP89FM42
Table 8-19 PBPRD Read Value
Set condition PBPRDi read value PBCRi 0 1 1 PBOUTCRi * 0 1 Contents of port "0" Contents of port
Note 1: * : Don't care Note 2: i = 4 to 7
RA005
Page 118
TMP89FM42
8.4 Serial Interface Selecting Function
On the TMP89FM42, the built-in serial interface (SIO, UART and I2C) communication pins and interrupt source assignment can be changed. Two out of three functions, SIO0, UART0 and I2C0, can be used at the same time by using this selecting function. The input pins of the 16-bit timer counter A0 input (TCA0 input) can be changed by using this selecting function.
UART1
Port
P90 (TXD1) P91 (RXD1)
Port Selector Selector UART0 0* 10 S SIO0 Selector I2C0 01 *0 S SERSEL Port S 1 0
PB4 (TXD0 / SO0) PB5 (RXD0 / SI0) PB6 (SCLK0)
Port
P20 (TXD0 / SO0) P21 (RXD0 / SI0) P22 (SCLK0)
P23 (SDA0 / SO0) P24 (SCL0 / SI0) P25 (SCLK0)
SERSEL Selector TCA0 00 01 10 S SERSEL Port P21 (RXD0) P91 (RXD1) P72 (TCA0)
Figure 8-11 Serial Interface Selecting Function
Serial interface selection control register
SERSEL (0x0FCB) 7 Bit Symbol Read/Write After reset R/W 0 TCA0SEL R/W 0 R 0 6 5 4 SRSEL2 R/W 0 R 0 R 0 R/W 0 3 2 1 SRSEL0 R/W 0 0
TCA0SEL
16-bit timer counter A0 input switching
00: 01: 10: 11: 0: 1: 00: 01: 10: 11:
P72 input (TCA0) P21 input (also used as RXD0) P91 input (also used as RXD1) Reserved Select P20, P21, P22 Select PB4, PB5, PB6 Select UART0, I2C0 Select UART0, SIO0 Select SIO0, I2C0 Reserved
SRSEL2
Select UART0/SIO0 input/output port
SRSEL0
Serial interface selection 0
Note 1: The operation for changing SERSEL must be executed while the applicable serial interface and timer counter operations are stopped. If SERSEL is switched during operation of these peripheral functions, each peripheral function may receive (transmit) unexpected data and operate improperly.
RA005
Page 119
8. I/O Ports
8.4 Serial Interface Selecting Function TMP89FM42
Note 2: It is recommended to clear the interrupt latch for the applicable serial interface immediately after changing SERSEL. Interrupt latches are common to INTRXD and INTSIO and to INTSBI and INTSIO. Therefore, if an interrupt occurs before or after SERSEL is switched, it is difficult to tell which function has caused the interrupt.
UART input/output change control register
UATCNG (0x0F57) 7 Bit Symbol Read/Write After reset R 0 6 R 0 5 R 0 4 R 0 3 R 0 2 R 0 1 UAT1IO R/W 0 0 UAT0IO R/W 0
RXD pin UAT1IO Select UART1 input/ output port 0: 1: P91 P90 SERSEL ="0" UAT0IO Select UART0 input/ output port 0: 1: P21 P20 PB5 PB4 P20 P21 SERSEL ="1" P90 P91
TXD pin
SERSEL ="0"
SERSEL ="1" PB4 PB5
Note 1: The operation for changing UATCNG must be executed while the applicable serial interface operations are stopped.
Table 8-20 Select input/output port and interrupt
SERSEL SERSEL UATCNG 0: 0: 1: 00: 0: 1: 1: 0: 0: 1: 01: 0: 1: 1: 0: 10: 1: 11: 0 or 1: 0 or 1: 0 or 1: SO0 SI0 SCLK 0 Note 1 Note 1 Note 1 Reserved 0 or 1: RXD0 Note 1 TXD0 Note 1 TXD0 RXD0 Note 1 Note 1 Note 1 Note 1 Note 1 SCLK 0 SDA0 SCL0 RXD0 Note 1 TXD0 Note 1 TXD0 RXD0 Note 1 Note 1 Note 1 TXD0 RXD0 Note 1 RXD0 TXD0 Note 1 Note 1 SO0 SI0 Port Interrupt UART0/SIO0 PB4 Note 1 PB5 Note 1 PB6 Note 1 P20 TXD0 RXD0 P21 RXD0 TXD0 P22 Note 1 SDA0 SCL0 P23 I2C0/SIO0 P24 P25 IL7 IL6 IL15
Note 1
INTTXD0
INTRXD0
INTSBI0
SCLK 0
INTTXD0
INTRXD0
INTSIO0
SO0
SI0
Note 1
-
INTSIO0
INTSBI0
Note 1: Can be used as a port. (Set the function register (PxFC) to "0".)
RA005
Page 120
TMP89FM42
8.5 Revision History
Rev
Description "Table 8-1 List of I/O Ports" Added description to P9 Port. "Table 8-2 List of I/O Port Settings" Added description of UART setting to P90 and P91. " Port P2 input/output control" Added RXD0(I) to P20. Added TXD0(O) to P21. "8.3.10 Port P8 (P81 to P80)" Added description about P8 Port. "8.3.11 Port P9 (P9741 to P90)" Deleted description about serial interface (SIO). "8.3.13 Port PB (PB75 to PB04)" Added detail description about PB port. "8.4 Serial Interface Selecting Function" Deleted description about SIO1 and UART1. "Figure 8-17 Serial Interface Selecting Function" Added PB Port. Deleted P92 and P94 Ports.Deleted SIO1. " Serial interface selection control register" Deleted SRSEL1. Revised SRSEL2 description from "output" to "input/output". Deleted Table 8-20. "Figure 8-2 Port P0 (P00, P01)", "Figure 8-3 Port P0 (P02, P03)" Added damping resistor (Ro). "Figure 8-4 Port P1" Deleted STOP control from P11 pin input. Defined symbol of programmable pull-up resistor to RIN3. Defined symbol of reset pull-up resister to RIN2.
RA002
RA003
RA004
"8.3.2 Port P1 (P13 to P10)" Deleted description of "or as a sink open drain output" "8.3.6 Port P4 (P47 to P40)" Deleted description of "or as a sink open drain output" "Figure 8-4 Port P1" Revised reset control signal.
RA005
RA005
Page 121
8. I/O Ports
8.5 Revision History TMP89FM42
RA005
Page 122
TMP89FM42
9. Special Function Registers
The TMP89FM42 adopts the memory mapped I/O system, and all peripheral hardware data control and transfer operations are performed through the special function registers (SFR). SFR1 is mapped on addresses 0x0000 to 0x003F, SFR2 is mapped on addresses 0x0F00 to 0x0FFF, and SFR3 is mapped on addresses 0x0E40 to 0x0EBF.
9.1 SFR1 (0x0000 to 0x003F)
Table 9-1 SFR1 (0x0000 to 0x003F)
Address 0x0000 0x0001 0x0002 0x0003 0x0004 0x0005 0x0006 0x0007 0x0008 0x0009 0x000A 0x000B 0x000C 0x000D 0x000E 0x000F 0x0010 0x0011 0x0012 0x0013 0x0014 0x0015 0x0016 0x0017 0x0018 0x0019 0x001A 0x001B 0x001C 0x001D 0x001E 0x001F Register Name P0DR P1DR P2DR Reserved P4DR Reserved Reserved P7DR P8DR P9DR Reserved PBDR Reserved P0PRD P1PRD P2PRD Reserved P4PRD Reserved Reserved P7PRD P8PRD P9PRD Reserved PBPRD Reserved UART0CR1 UART0CR2 UART0DR UART0SR TD0BUF/RD0BUF SIO0CR Address 0x0020 0x0021 0x0022 0x0023 0x0024 0x0025 0x0026 0x0027 0x0028 0x0029 0x002A 0x002B 0x002C 0x002D 0x002E 0x002F 0x0030 0x0031 0x0032 0x0033 0x0034 0x0035 0x0036 0x0037 0x0038 0x0039 0x003A 0x003B 0x003C 0x003D 0x003E 0x003F Register Name SIO0SR SIO0BUF SBI0CR1 SBI0CR2/SBI0SR2 I2C0AR SBI0DBR T00REG T01REG T00PWM T01PWM T00MOD T01MOD T001CR TA0DRAL TA0DRAH TA0DRBL TA0DRBH TA0MOD TA0CR TA0SR ADCCR1 ADCCR2 ADCDRL ADCDRH DVOCR TBTCR EIRL EIRH EIRE EIRD Reserved PSW
Note 1: Do not access reserved addresses by the program.
RA001
Page 123
9. Special Function Registers
9.2 SFR2 (0x0F00 to 0x0FFF) TMP89FM42
9.2 SFR2 (0x0F00 to 0x0FFF)
Table 9-2
Address 0x0F00 0x0F01 0x0F02 0x0F03 0x0F04 0x0F05 0x0F06 0x0F07 0x0F08 0x0F09 0x0F0A 0x0F0B 0x0F0C 0x0F0D 0x0F0E 0x0F0F 0x0F10 0x0F11 0x0F12 0x0F13 0x0F14 0x0F15 0x0F16 0x0F17 0x0F18 0x0F19 0x0F1A 0x0F1B 0x0F1C 0x0F1D 0x0F1E 0x0F1F
SFR2 (0x0F00 to 0x0F7F)
Register Name Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved P0CR P1CR P2CR Reserved P4CR Reserved Address 0x0F20 0x0F21 0x0F22 0x0F23 0x0F24 0x0F25 0x0F26 0x0F27 0x0F28 0x0F29 0x0F2A 0x0F2B 0x0F2C 0x0F2D 0x0F2E 0x0F2F 0x0F30 0x0F31 0x0F32 0x0F33 0x0F34 0x0F35 0x0F36 0x0F37 0x0F38 0x0F39 0x0F3A 0x0F3B 0x0F3C 0x0F3D 0x0F3E 0x0F3F Register Name Reserved P7CR P8CR P9CR Reserved PBCR Reserved P0PU P1PU P2PU Reserved P4PU Reserved Reserved Reserved Reserved P9PU Reserved Reserved Reserved P0FC Reserved P2FC Reserved P4FC Reserved Reserved P7FC P8FC P9FC Reserved PBFC Address 0x0F40 0x0F41 0x0F42 0x0F43 0x0F44 0x0F45 0x0F46 0x0F47 0x0F48 0x0F49 0x0F4A 0x0F4B 0x0F4C 0x0F4D 0x0F4E 0x0F4F 0x0F50 0x0F51 0x0F52 0x0F53 0x0F54 0x0F55 0x0F56 0x0F57 0x0F58 0x0F59 0x0F5A 0x0F5B 0x0F5C 0x0F5D 0x0F5E 0x0F5F Register Name Reserved Reserved Reserved P2OUTCR Reserved Reserved Reserved Reserved Reserved Reserved P9OUTCR Reserved PBOUTCR Reserved Reserved Reserved Reserved Reserved Reserved Reserved UART1CR1 UART1CR2 UART1DR UART1SR TD1BUF/RD1BUF Reserved Reserved Reserved Reserved Reserved Reserved Reserved Address 0x0F60 0x0F61 0x0F62 0x0F63 0x0F64 0x0F65 0x0F66 0x0F67 0x0F68 0x0F69 0x0F6A 0x0F6B 0x0F6C 0x0F6D 0x0F6E 0x0F6F 0x0F70 0x0F71 0x0F72 0x0F73 0x0F74 0x0F75 0x0F76 0x0F77 0x0F78 0x0F79 0x0F7A 0x0F7B 0x0F7C 0x0F7D 0x0F7E 0x0F7F Register Name Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved POFFCR0 POFFCR1 POFFCR2 POFFCR3 Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved
Note 1: Do not access reserved addresses by the program.
RA001
Page 124
TMP89FM42
Table 9-3
Address 0x0F80 0x0F81 0x0F82 0x0F83 0x0F84 0x0F85 0x0F86 0x0F87 0x0F88 0x0F89 0x0F8A 0x0F8B 0x0F8C 0x0F8D 0x0F8E 0x0F8F 0x0F90 0x0F91 0x0F92 0x0F93 0x0F94 0x0F95 0x0F96 0x0F97 0x0F98 0x0F99 0x0F9A 0x0F9B 0x0F9C 0x0F9D 0x0F9E 0x0F9F
SFR2 (0x0F80 to 0x0FFF)
Register Name Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved T02REG T03REG T02PWM T03PWM T02MOD T03MOD T023CR Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Address 0x0FA0 0x0FA1 0x0FA2 0x0FA3 0x0FA4 0x0FA5 0x0FA6 0x0FA7 0x0FA8 0x0FA9 0x0FAA 0x0FAB 0x0FAC 0x0FAD 0x0FAE 0x0FAF 0x0FB0 0x0FB1 0x0FB2 0x0FB3 0x0FB4 0x0FB5 0x0FB6 0x0FB7 0x0FB8 0x0FB9 0x0FBA 0x0FBB 0x0FBC 0x0FBD 0x0FBE 0x0FBF Register Name Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved TA1DRAL TA1DRAH TA1DRBL TA1DRBH TA1MOD TA1CR TA1SR Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Address 0x0FC0 0x0FC1 0x0FC2 0x0FC3 0x0FC4 0x0FC5 0x0FC6 0x0FC7 0x0FC8 0x0FC9 0x0FCA 0x0FCB 0x0FCC 0x0FCD 0x0FCE 0x0FCF 0x0FD0 0x0FD1 0x0FD2 0x0FD3 0x0FD4 0x0FD5 0x0FD6 0x0FD7 0x0FD8 0x0FD9 0x0FDA 0x0FDB 0x0FDC 0x0FDD 0x0FDE 0x0FDF Register Name Reserved Reserved Reserved Reserved KWUCR0 KWUCR1 VDCR1 VDCR2 RTCCR Reserved Reserved SERSEL IRSTSR WUCCR WUCDR CGCR FLSCR1 FLSCR2/FLSCRM FLSSTB SPCR WDCTR WDCDR WDCNT WDST EINTCR1 EINTCR2 EINTCR3 EINTCR4 SYSCR1 SYSCR2 SYSCR3 SYSCR4/SYSSR4 Address 0x0FE0 0x0FE1 0x0FE2 0x0FE3 0x0FE4 0x0FE5 0x0FE6 0x0FE7 0x0FE8 0x0FE9 0x0FEA 0x0FEB 0x0FEC 0x0FED 0x0FEE 0x0FEF 0x0FF0 0x0FF1 0x0FF2 0x0FF3 0x0FF4 0x0FF5 0x0FF6 0x0FF7 0x0FF8 0x0FF9 0x0FFA 0x0FFB 0x0FFC 0x0FFD 0x0FFE 0x0FFF Register Name ILL ILH ILE ILD Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved ILPRS1 ILPRS2 ILPRS3 ILPRS4 ILPRS5 ILPRS6 Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved
Note 1: Do not access reserved addresses by the program.
RA001
Page 125
9. Special Function Registers
9.3 SFR3 (0x0E40 to 0x0EFF) TMP89FM42
9.3 SFR3 (0x0E40 to 0x0EFF)
Table 9-4
Address 0x0E40 0x0E41 0x0E42 0x0E43 0x0E44 0x0E45 0x0E46 0x0E47 0x0E48 0x0E49 0x0E4A 0x0E4B 0x0E4C 0x0E4D 0x0E4E 0x0E4F 0x0E50 0x0E51 0x0E52 0x0E53 0x0E54 0x0E55 0x0E56 0x0E57 0x0E58 0x0E59 0x0E5A 0x0E5B 0x0E5C 0x0E5D 0x0E5E 0x0E5F
SFR3 (0x0E40 to 0x0EBF)
Register Name Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved UATCNG Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Address 0x0E60 0x0E61 0x0E62 0x0E63 0x0E64 0x0E65 0x0E66 0x0E67 0x0E68 0x0E69 0x0E6A 0x0E6B 0x0E6C 0x0E6D 0x0E6E 0x0E6F 0x0E70 0x0E71 0x0E72 0x0E73 0x0E74 0x0E75 0x0E76 0x0E77 0x0E78 0x0E79 0x0E7A 0x0E7B 0x0E7C 0x0E7D 0x0E7E 0x0E7F Register Name Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Address 0x0E80 0x0E81 0x0E82 0x0E83 0x0E84 0x0E85 0x0E86 0x0E87 0x0E88 0x0E89 0x0E8A 0x0E8B 0x0E8C 0x0E8D 0x0E8E 0x0E8F 0x0E90 0x0E91 0x0E92 0x0E93 0x0E94 0x0E95 0x0E96 0x0E97 0x0E98 0x0E99 0x0E9A 0x0E9B 0x0E9C 0x0E9D 0x0E9E 0x0E9F Register Name Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Address 0x0EA0 0x0EA1 0x0EA2 0x0EA3 0x0EA4 0x0EA5 0x0EA6 0x0EA7 0x0EA8 0x0EA9 0x0EAA 0x0EAB 0x0EAC 0x0EAD 0x0EAE 0x0EAF 0x0EB0 0x0EB1 0x0EB2 0x0EB3 0x0EB4 0x0EB5 0x0EB6 0x0EB7 0x0EB8 0x0EB9 0x0EBA 0x0EBB 0x0EBC 0x0EBD 0x0EBE 0x0EBF Register Name Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved
Note 1: Do not access reserved addresses by the program.
RA001
Page 126
TMP89FM42
Table 9-5
Address 0x0EC0 0x0EC1 0x0EC2 0x0EC3 0x0EC4 0x0EC5 0x0EC6 0x0EC7 0x0EC8 0x0EC9 0x0ECA 0x0ECB 0x0ECC 0x0ECD 0x0ECE 0x0ECF
SFR3 (0x0EC0 to 0x0EFF)
Register Name Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Address 0x0ED0 0x0ED1 0x0ED2 0x0ED3 0x0ED4 0x0ED5 0x0ED6 0x0ED7 0x0ED8 0x0ED9 0x0EDA 0x0EDB 0x0EDC 0x0EDD 0x0EDE 0x0EDF Register Name Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Address 0x0EE0 0x0EE1 0x0EE2 0x0EE3 0x0EE4 0x0EE5 0x0EE6 0x0EE7 0x0EE8 0x0EE9 0x0EEA 0x0EEB 0x0EEC 0x0EED 0x0EEE 0x0EEF Register Name Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Address 0x0EF0 0x0EF1 0x0EF2 0x0EF3 0x0EF4 0x0EF5 0x0EF6 0x0EF7 0x0EF8 0x0EF9 0x0EFA 0x0EFB 0x0EFC 0x0EFD 0x0EFE 0x0EFF Register Name Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved
Note 1: Do not access reserved addresses by the program.
RA001
Page 127
9. Special Function Registers
9.3 SFR3 (0x0E40 to 0x0EFF) TMP89FM42
RA001
Page 128
TMP89FM42
10. Low Power Consumption Function for Peripherals
The TMP89FM42 has low power consumption registers (POFFCRn) that save power when specific peripheral functions are unused. Each bit of the low power consumption registers can be set to enable or disable each peripheral function. (n = 0, 1, 2, 3) The basic clock supply to each peripheral function is disabled for power saving, by setting the corresponding bit of the low power consumption registers (POFFCRn) to "0". (The disabled peripheral functions become unavailable.) The basic clock supply to each peripheral function is enabled and the function becomes available by setting the corresponding bit of the low power consumption registers (POFFCRn) to "1". After reset, the low power consumption registers (POFFCRn) are initialized to "0", and thus the peripheral functions are unavailable. When each peripheral function is used for the first time, be sure to set the corresponding bit of the low power consumption registers (POFFCRn) to "1" in the initial settings of the program (before operating the control register for the peripheral function). When a peripheral function is operating, the corresponding bit of the low power consumption registers (POFFCRn) must not be changed to "0". If it is changed, the peripheral function may operate unexpectedly.
RA001
Page 129
10. Low Power Consumption Function for Peripherals
TMP89FM42
10.1 Control
The low power consumption function is controlled by the low power consumption registers (POFFCRn). (n = 0, 1, 2, 3) Low power consumption register 0
POFFCR0 (0x0F74) Bit Symbol Read/Write After reset 7 R/W 0 6 R/W 0 5 TC023EN R/W 0 4 TC001EN R/W 0 3 R/W 0 2 R/W 0 1 TCA1EN R/W 0 0 TCA0EN R/W 0
TC023EN
TC02,03 control
0 1 0 1 0 1 0 1
Disable Enable Disable Enable Disable Enable Disable Enable
TC001EN
TC00,01 control
TCA1EN
TCA1 control
TCA0EN
TCA0 control
Low power consumption register 1
POFFCR1 (0x0F75) Bit Symbol Read/Write After reset 7 R/W 0 6 R/W 0 5 R/W 0 4 SBI0EN R/W 0 3 R/W 0 2 R/W 0 1 UART1EN R/W 0 0 UART0EN R/W 0
SBI0EN
I2C0 control
0 1 0 1 0 1
Disable Enable Disable Enable Disable Enable
UART1EN
UART1 control
UART0EN
UART0 control
Low power consumption register 2
POFFCR2 (0x0F76) Bit Symbol Read/Write After reset 7 R/W 0 6 R/W 0 5 RTCEN R/W 0 4 R/W 0 3 R/W 0 2 R/W 0 1 R/W 0 0 SIO0EN R/W 0
RTCEN
RTC control
0 1 0 1
Disable Enable Disable Enable
SIO0EN
SIO0 control
Low power consumption register 3
POFFCR3 (0x0F77) Bit Symbol Read/Write After reset 7 R/W 0 6 R/W 0 5 INT5EN R/W 0 4 INT4EN R/W 0 3 INT3EN R/W 0 2 INT2EN R/W 0 1 INT1EN R/W 0 0 INT0EN R/W 0
RA001
Page 130
TMP89FM42
INT5EN
INT5 control
0 1 0 1 0 1 0 1 0 1 0 1
Disable Enable Disable Enable Disable Enable Disable Enable Disable Enable Disable Enable
INT4EN
INT4 control
INT3EN
INT3 control
INT2EN
INT2 control
INT1EN
INT1 control
INT0EN
INT0 control
RA001
Page 131
10. Low Power Consumption Function for Peripherals
TMP89FM42
RA001
Page 132
TMP89FM42
11. Divider Output (DVO)
This function outputs approximately 50% duty pulses that can be used to drive the piezoelectric buzzer or other device.
11.1 Configuration
fcgck/212 or fs/25 fcgck/211 or fs/24 fcgck/210 or fs/23 fcgck/29
Selector A B CY D S 2 DVOCK DVOCR DVOEN
DVO pin
Figure 11-1 Divider Output
11.2 Control
The divider output is controlled by the divider output control register (DVOCR). Divider output control register
DVOCR (0x0038) 7 Bit Symbol Read/Write After reset R 0 6 R 0 5 R 0 4 R 0 3 R 0 2 DV0EN R/W 0 0 1 DVOCK R/W 0 0
DVOEN
Enables/disables the divider output
0: Disable the divider output 1: Enable the divider output NORMAL 1/2, IDLE 1/2 mode DV9CK=0 DV9CK=1 fs/25 fs/24 fs/23 Reserved SLOW1/2 SLEEP1 mode fs/25 fs/24 fs/23 Reserved
DVOCK
Selects the divider output frequency Unit: [Hz]
00 01 10 11
fcgck/212 fcgck/211 fcgck/210 fcgck/29
Note 1: fcgck: Gear clock [Hz], fs: Low-frequency clock [Hz] Note 2: DVOCR is cleared to "0" when the operation is switched to STOP or IDLE0/SLEEP0 mode. DVOCR holds the value. Note 3: When SYSCR1 is "1" in the NORMAL 1/2 or IDLE 1/2 mode, the DVO frequency is subject to some fluctuations to synchronize fs and fcgck. Note 4: Bits 7 to 3 of DVOCR are read as "0".
11.2.1 Function
Select the divider output frequency at DVOCR. RA001 Page 133
11. Divider Output (DVO)
11.2 Control TMP89FM42
The divider output is enabled by setting DVOCR to "1". Then, The rectangular waves selected by DVOCR is output from DVO pin. It is disabled by clearing DVOVR to "0". And DVO pin keeps "H" level. When the operation is changed to STOP or IDLE0/SLEEP0 mode, DVOCR is cleared to "0" and the DVO pin outputs the "H" level. The divider output source clock operates, regardless of the value of DVOCR. Therefore, the frequency of the first divider output after DVOCR is set to "1" is not the frequency set at DVOCR. When the operation is changed to the software, STOP or IDLE0/SLEEP0 mode is activated and DVOCR is cleared to "0", the frequency of the divider output is not the frequency set at DVOCR.
TBTCR
DVO output Divider output timing chart
Figure 11-2 Divider Output Timing
When the operation is changed from NORMAL mode to SLOW mode or from SLOW mode to NORMAL mode, the divider output frequency does not reach the expected value due to synchronization of the gear clock (fcgck) and the low-frequency clock (fs).
Example: 2.441 kHz pulse output (fcgck = 10.0 MHz)
LD (DVOCR), 00000100B ; DVOCK "00", DVOEN "1"
Table 11-1 Divider Output Frequency (Example: fcgck = 10.0 MHz, fs = 32.768 kHz)
Divider output frequency [Hz] DVOCK NORMAL 1/2, IDLE 1/2 mode DV9CK = 0 00 01 10 11 2.441 k 4.883 k 9.766 k 19.531 k DV9CK = 1 1.024 k 2.048 k 4.096 k Reserved SLOW1/2, SLEEP1 mode 1.024 k 2.048 k 4.096 k Reserved
RA001
Page 134
TMP89FM42
11.3 Revision History
Rev RA001 Deleted SLEEP2 description.
Description
RA001
Page 135
11. Divider Output (DVO)
11.3 Revision History TMP89FM42
RA001
Page 136
TMP89FM42
12. Time Base Timer (TBT)
The time base timer generates the time base for key scanning, dynamic display and other processes. It also provides a time base timer interrupt (INTTBT) in a certain cycle.
12.1 Time Base Timer
12.1.1 Configuration
fcgck/222 or fs/215 fcgck/220 or fs/213 fcgck/215 or fs/28 fcgck/213 or fs/26 fcgck/212 or fs/25 fcgck/211 or fs/24 fcgck/210 or fs/23 fcgck/28
Source clock
Falling edge detector
IDLE0, SLEEP0 Release request
3 TBTCK TBTCR TBTEN
Figure 12-1 Time Base Timer Configuration
Selector
INTTBT Interrupt request
12.1.2 Control
The time base timer is controlled by the time base timer control register (TBTCR). Time base timer control register
TBTCR (0x0039) 7 Bit Symbol Read/Write After reset R 0 6 R 0 5 R 0 4 R 0 3 TBTEN R/W 0 0 2 1 TBTCK R/W 0 0 0
TBTEN
Enables/disables the time base timer interrupt requests
0: Disables generation of interrupt request signals 1: Enables generation of interrupt request signals NORMAL 1/2, IDLE 1/2 mode TBTCK DV9CK = 0 000 001 fcgck/222 fcgck/220 fcgck/215 fcgck/213 fcgck/2
12
DV9CK = 1 fs/215 fs/213 fs/28 fs/26 fs/2
5
SLOW1/2, SLEEP1 mode fs/215 fs/213 Reserved Reserved Reserved Reserved Reserved Reserved
TBTCK
Selects the time base timer interrupt frequency Unit: [Hz]
010 011 100 101 110 111
fcgck/211 fcgck/2
10
fs/24 fs/2
3
fcgck/28
Reserved
Note 1: fcgck : Gear clock [Hz], fs : Low-frequency clock [Hz] Note 2: When the operation is changed to the STOP mode, TBTCR is cleared to "0" and TBTCR maintains the value.
RA001
Page 137
12. Time Base Timer (TBT)
12.1 Time Base Timer TMP89FM42
Note 3: TBTCR should be set when TBTCR is "0". Note 4: When SYSCR1 is "1" in the NORMAL 1/2 or IDLE1/2 mode, the interrupt request is subject to some fluctuations to synchronize fs and fcgck. Note 5: Bits 7 to 4 of TBTCR are read as "0".
12.1.3 Functions
Select the source clock frequency for the time base timer by TBTCR. TBTCR should be changed when TBTCR is "0". Otherwise, the INTTBT interrupt request is generated at unexpected timing. Setting TBTCR to "1" causes interrupt request signals to occur at the falling edge of the source clock. When TBTCR is cleared to "0", no interrupt request signal will occur. When the operation is changed to the STOP mode, TBTCR is cleared to "0". The source clock of the time base timer operates regardless of the TBTCR value. A time base timer interrupt is generated at the first falling edge of the source clock after a time base timer interrupt request is enabled. Therefore, the period from when the time TBTCR is set to "1" to the time when the first interrupt request occurs is shorter than the frequency period set at TBTCR.
Source clock
TBTCR
INTTBT interrupt request Interrupt period Time base timer enable
Figure 12-2 Time Base Timer Interrupt
When the operation is changed from NORMAL mode to SLOW mode or from SLOW mode to NORMAL mode, The interrupt request will not occur at the expected timing due to synchronization of the gear clock (fcgck) and the low-frequency clock (fs). It is recommened that the operation mode is changed when TBTCR is "0". Table 12-1 Time Base Timer Interrupt Frequency (Example: when fcgck = 10.0 MHz and fs = 32.768 kHz)
Time base timer interrupt frequency [Hz] TBTCK NORMAL1/2, IDLE1/2 mode DV9CK = 0 000 001 010 011 100 101 110 111 2.38 9.54 305.18 1220.70 2441.41 4882.81 9765.63 39062.5 NORMAL1/2, IDLE1/2 mode SLOW1/2, SLEEP1 mode DV9CK = 1 1 4 128 512 1024 2048 4096 Reserved 1 4 Reserved Reserved Reserved Reserved Reserved Reserved
Example: Set the time base timer interrupt frequency to fcgck/215 [Hz] and enable interrupts.
RA001
Page 138
TMP89FM42
DI SET EI LD LD (TBTCR), 0y00000010 (TBTCR), 0y00001010 (EIRL). 5
; IMF 0 ; Set the interrupt enable register ; IMF 1 ; Set the interrupt frequency ; Enable generation of interrupt request signals
RA001
Page 139
12. Time Base Timer (TBT)
12.2 Revision History TMP89FM42
12.2 Revision History
Rev RA001 Deleted SLEEP2 description
Description
RA001
Page 140
TMP89FM42
13. 16-bit Timer Counter (TCA)
The TMP89FM42 contains 2 channels of high-performance 16-bit timer counters (TCA). This chapter describes the 16-bit timer counter A0. For the 16-bit timer counter A1, replace the SFR addresses and pin names, as shown in Table 13-1 and Table 13-2. Table 13-1 SFR Address Assignment
TAxDRAL (Address) TA0DRAL (0x002D) TA1DRAL (0x0FA8) TAxDRAH (Address) TA0DRAH (0x002E) TA1DRAH (0x0FA9) TAxDRBL (Address) TA0DRBL (0x002F) TA1DRBL (0x0FAA) TAxDRBH (Address) TA0DRBH (0x0030) TA1DRBH (0x0FAB) TAxMOD (Address) TA0MOD (0x0031) TA1MOD (0x0FAC) TAxCR (Address) TA0CR (0x0032) TA1CR (0x0FAD) TAxSR (Address) TA0SR (0x0033) TA1SR (0x0FAE) Low power consumption register POFFCR0 POFFCR0
Timer counter A0
Timer counter A1
Table 13-2 Pin Names
Timer input pin Timer counter A0 Timer counter A1 TCA0 pin TCA1 pin PPG output pin
PPGA0 pin PPGA1 pin
RA001
Page 141
13.1 Configuration
13. 16-bit Timer Counter (TCA)
TA0CK
TA0M
TA0DBE
TA0TED
TA0METT
TA0NC
TA0OVE
TA0CAP
TA0S
TA0TFF
TA0MPPG
TA0CPFB
TA0CPFA
TA0MOD
TA0CR
Clear TA0S
TA0SR
TMP89FM42
Internal bus
TA0OVF
RA001
Internal bus Reading and writing of TA0DRBL Temporary buffer
Selector Selector Selector
Reading and writing of TA0DRBH
Reading and writing of TA0DRAH Temporary buffer 1 0
Reading and writing of TA0DRAL
Selector
13.1 Configuration
TA0DBE
0
1
1
0
0
1
TA0NC 2
Double buffer (16 bits)
Double buffer (16 bits)
TCA0 pin input
Selector Selector Selector Selector
Noise canceller
0 TA0DRBH TA0DRBL TA0DRAH TA0DRAL
Edge detection 1 Edge detection 2 TAMCAP Comparator Capture control Match detection Capture control Edge detection 2 Comparator Match detection
1
1
0
0
1
1
0
Pulse width measurement mode
TA0TED
TA0CAP
Auto capture control
External trigger input selection
Edge detection 1 Edge detection 2
Edge detection 1
INTTA0 interrupt request
Count up
Figure 13-1 Timer Counter A0
16-bit up counter
Overflow Count clear Timer start control 0 1
Page 142
Y
0 1
Y
S
TA0OVE
fcgck/210 or fs/23 fcgck/26 fcgck/22 fcgck/2
E A B C D
Window mode
S0 S1
PPG mode
2
Event counter mode
Timer F/F
EN PPG mode
PPGA0 output
Decorder
External trigger timer mode
3
Pulse width measurement mode
Edge detection 1 Edge detection 2
TA0TED Edge detection 1 Edge detection 2 Falling Rising Rising Falling
TMP89FM42
13.2 Control
Timer Counter A0 is controlled by the low power consumption register (POFFCR0), the timer counter A0 mode register (TA0MOD), the timer counter A0 control register (TA0CR) and two 16-bit timer A0 registers (TA0DRA and TA0DRB). Low power consumption register 0
POFFCR0 (0x0F74) Bit Symbol Read/Write After reset 7 R/W 0 6 R/W 0 5 TC023EN R/W 0 4 TC001EN R/W 0 3 R/W 0 2 R/W 0 1 TCA1EN R/W 0 0 TCA0EN R/W 0
TC023EN
TC02,03 control
0 1 0 1 0 1 0 1
Disable Enable Disable Enable Disable Enable Disable Enable
TC001EN
TC00,01 control
TCA1EN
TCA1 control
TCA0EN
TCA0 control
RA001
Page 143
13. 16-bit Timer Counter (TCA)
13.2 Control TMP89FM42
Timer counter A0 mode register
TA0MOD (0x0031) Bit Symbol Read/Write After reset 7 TA0DBE R/W 1 6 TA0TED R/W 0 5 TA0MCAP TA0METT R/W 0 0 4 TA0CK R/W 0 0 3 2 1 TA0M R/W 0 0 0
TA0DBE
Double buffer control
0 1 0 1 0 1 0 1
Disable the double buffer Enable the double buffer Rising edge/H level Falling edge/L level Double edge capture Single edge capture Trigger start Trigger start & stop NORMAL 1/2 or IDLE 1/2 mode SYSCR1 ="0" SYSCR1 ="1" fs/23 fcgck/26 fcgck/22 fcgck/2 SLOW1/2 or SLEEP1 mode fs/23 -
TA0TED
External trigger input selection Pulse width measurement mode control External trigger timer mode control
TA0MCAP
TA0METT
TA0CK
Timer counter 1 source clock selection
00 01 10 11 000 001 010
fcgck/210 fcgck/26 fcgck/22 fcgck/2 Timer mode Timer mode Event counter mode
TA0M
Timer counter 1 operation mode selection
011 100 101 110 111
PPG output mode (Software start) External trigger timer mode Window mode Pulse width measurement mode Reserved
Note 1: fcgck, Gear clock [Hz]; fs, Low-frequency clock [Hz] Note 2: Set TA0MOD in the stopped state (TA0CR="0"). Writing to TA0MOD is invalid during the operation (TA0CR="1").
RA001
Page 144
TMP89FM42
Timer counter A0 control register
TA0CR (0x0032) Bit Symbol Read/Write After reset 7 TA0OVE R/W 0 6 TA0TFF R/W 1 0 5 TA0NC R/W 0 4 3 R 0 2 R 0 1 TA0CAP TA0MPPG R/W 0 0 TA0S R/W 0
0 TA0OVE Overflow interrupt control 1
Generate no INTTA0 interrupt request when the counter overflow occurs. Generate an INTTA0 interrupt request when the counter overflow occurs. Clear Set NORMAL 1/2 or IDLE 1/2 mode SLOW1/2 or SLEEP1 mode No noise canceller fs/2
TA0TFF
Timer F/F control
0 1
00 TA0NC Noise canceller sampling interval setting 01 10 11 TA0ACAP Auto capture function 0 1 0 1 0 1
No noise canceller fcgck/2 fcgck/22 fcgck/2
8
Disable the auto capture Enable the auto capture Continuous One-shot Stop & counter clear Start
TA0MPPG
PPG output control
TA0S
Timer counter A start control
Note 1: The auto capture can be used only in the timer, event counter, external trigger timer and window modes. Note 2: Set TA0TFF, TA0OVE and TA0NC in the stopped state (TA0S="0"). Writing is invalid during the operation (TA0S="1"). Note 3: When the STOP mode is started, the start control (TA0S) is automatically cleared to "0" and the timer stops. Set TA0S again to use the timer counter after the release of the STOP mode. Note 4: When a read instruction is executed on TA0CR, bits 3 and 2 are read as "0". Note 5: Do not set TA0NC to "01" or "10" when the SLOW 1/2 or SLEEP 1 mode is used. Setting TA0NC to "01" or "10" stops the noise canceller and no signal is input to the timer.
RA001
Page 145
13. 16-bit Timer Counter (TCA)
13.2 Control TMP89FM42
Timer counter A0 status register
TA0SR (0x0033) Bit Symbol Read/Write After reset 7 TA0OVF R 0 6 R 0 5 R 0 4 R 0 3 R 0 2 R 0 1 TA0CPFA R 0 0 TA0CPFB R 0
TA0OVF
Overflow flag
0 1 0 1
No overflow has occurred. At least an overflow has occurred. No capture operation has been executed. At least a pulse width capture has been executed in the double-edge capture. No capture operation has been executed. At least a capture operation has been executed in the single-edge capture. At least a pulse duty width capture has been executed in the doubleedge capture.
TA0CPFA
Capture completion flag A
0 1 TA0CPFB Capture completion flag B
Note 1: TA0OVF, TA0CPFA and TA0CPFB are cleared to "0" automatically after TA0SR is read. Writing to TA0SR is invalid. Note 2: When a read instruction is executed on TA0SR, bits 6 to 2 are read as "0".
Timer counter A0 register AH
TA0DRAH (0x002E) Bit Symbol Read/Write After reset 1 1 1 1 15 14 13 12 TA0DRAH R/W 1 1 1 1 11 10 9 8
Timer counter A0 register AL
TA0DRAL (0x002D) Bit Symbol Read/Write After reset 1 1 1 1 7 6 5 4 TA0DRAL R/W 1 1 1 1 3 2 1 0
Timer counter A0 register BH
TA0DRBH (0x0030) Bit Symbol Read/Write After reset 1 1 1 1 15 14 13 12 TA0DRBH R/W 1 1 1 1 11 10 9 8
Timer counter A0 register BL
TA0DRBL (0x002F) Bit Symbol Read/Write After reset 1 1 1 1 7 6 5 4 TA0DRBL R/W 1 1 1 1 3 2 1 0
Note 1: When a write instruction is executed on TA0DRAL (TA0DRBL), the set value does not become effective immediately, but is temporarily stored in the temporary buffer. Subsequently, when a write instruction is executed on the higher-level register, TA0DRAH (TA0DRBH), the 16-bit set values are collectively stored in the double buffer or TA0DRAL/H. When setting data to the timer counter A0 register, be sure to write the data into the lower level register and the higher level in this order. Note 2: The timer counter A0 register is not writable in the pulse width measurement mode.
RA001
Page 146
TMP89FM42
13.3 Low Power Consumption Function
Timer counter A0 has the low power consumption register (POFFCR0) that saves power consumption when the timer is not used. Setting POFFCR0 to "0" disables the basic clock supply to timer counter A0 to save power. Note that this makes the timer unusable. Setting POFFCR0 to "1" enables the basic clock supply to timer counter A0 and allows the timer to operate. After reset, POFFCR0 is initialized to "0", and this makes the timer unusable. When using the timer for the first time, be sure to set POFFCR0 to "1" in the initial setting of the program (before the timer control register is operated). Do not change POFFCR0 to "0" during the timer operation. Otherwise timer counter A0 may operate unexpectedly.
RA001
Page 147
13. 16-bit Timer Counter (TCA)
13.4 Timer Function TMP89FM42
13.4 Timer Function
Timer counter A0 has six types of operation modes; timer, external trigger timer, event counter, window, pulse width measurement and programmable pulse generate (PPG) output modes.
13.4.1 Timer mode
In the timer mode, the up-counter counts up using the internal clock, and interrupts can be generated regularly at specified times.
13.4.1.1 Setting
Setting the operation mode selection TA0MOD to "000" or "001" activates the timer mode. Select the source clock at TA0MOD. Setting TA0CR to "1" starts the timer operation. After the timer is started, writing to TA0MOD and TA0CR becomes invalid. Be sure to complete the required mode settings before starting the timer. Table 13-3 Timer Mode Resolution and Maximum Time Setting
Source clock [Hz] TA0MOD NORMAL 1/2 or IDLE 1/2 mode SYSCR1 = "0" fcgck/210 fcgck/26 fcgck/22 fcgck/2 SYSCR1 = "1" fs/23 fcgck/26 fcgck/22 fcgck/2 SLOW1/2 or SLEEP1 mode fcgck=10MHz fs=32.768KHz fcgck=10MHz fs=32.768KHz Resolution Maximum time setting
00 01 10 11
fs/23 -
102.4s 6.4s 400ns 200ns
244.1us -
6.7s 419.4ms 26.2ms 13.1ms
16s -
13.4.1.2 Operation
Setting TA0CR to "1" allows the 16-bit up counter to increment based on the selected internal source clock. When a match between the up-counter value and the value set to timer register A (TA0DRA) is detected, an INTTA0 interrupt request is generated and the up counter is cleared to "0000H". After being cleared, the up counter continues counting. Setting TA0CR to "0" during the timer operation causes the up counter to stop counting and be cleared to "0000H".
13.4.1.3 Auto capture
The latest contents of the up counter can be taken into timer register B (TA0DRB) by setting TA0CR to "1" (auto capture function). When TA0CR is "1", the current contents of the up counter can be read by reading TA0DRBL. TA0DRBH is loaded at the same time as TA0DRBL is read. Therefore, when reading the captured value, be sure to read TA0DRBL and TA0DRBH in this order. (The capture time is the timing when TA0DRBL is read.) The auto capture function can be used whether the timer is operating or stopped. When the timer is stopped, TA0DRBL is read as "00H". TA0DRBH keeps the captured value after the timer stops, but it is cleared to "00H" when TA0DRBL is read while the timer is stopped. If the timer is started with TA0CR written to "1", the auto capture is enabled immediately after the timer is started.
Note 1: The value set to TA0CR cannot be changed at the same time as TA0CR is rewritten from "1" to "0". (This setting is invalid.)
RA001
Page 148
TMP89FM42
13.4.1.4 Register buffer configuration
(1) Temporary buffer The TMP89FM42 contains an 8-bit temporary buffer. When a write instruction is executed on TA0DRAL, the data is first stored into this temporary buffer, whether the double buffer is enabled or disabled. Subsequently, when a write instruction is executed on TA0DRAH, the set value is stored into the double buffer or TA0DRAH. At the same time, the set value in the temporary buffer is stored into the double buffer or TA0DRAL. (This structure is designed to enable the set values of the lowerlevel and higher-level registers simultaneously.) Therefore, when setting data to TA0DRA, be sure to write the data into TA0DRAL and TA0DRAH in this order. See Figure 13-1 for the temporary buffer configuration.
(2)
Double buffer In the TMP89FM42, the double buffer can be used by setting TA0CR. Setting TA0CR to "0" disables the double buffer. Setting TA0CR to "1" enables the double buffer. See Figure 13-1 for the double buffer configuration. - When the double buffer is enabled When a write instruction is executed on TA0DRAH during the timer operation, the set value is first stored into the double buffer, and TA0DRAH/L are not updated immediately. TA0DRAH/L compare the up counter value to the last set values. If the values are matched, an INTTCA0 interrupt request is generated and the double buffer set value is stored in TA0DRAH/L. Subsequently, the match detection is executed using a new set value. When a read instruction is executed on TA0DRAH/L, the double buffer value (the last set value) is read, rather than the TA0DRAH/L values (the current effective values). When a write instruction is executed on TA0DRAH/L while the timer is stopped, the set value is immediately stored into both the double buffer and TA0DRAH/L. - When the double buffer is disabled When a write instruction is executed on TA0DRAH during the timer operation, the set value is immediately stored into TA0DRAH/L. Subsequently, the match detection is executed using a new set value. If the values set to TA0DRAH/L are smaller than the up counter value, the match detection is executed using a new set value after the up counter overflows. Therefore, the interrupt request interval may be longer than the selected time. If that is a problem, enable the double buffer. When a write instruction is executed on TA0DRAH/L while the timer is stopped, the set value is immediately stored into TA0DRAH/L.
RA001
Page 149
13. 16-bit Timer Counter (TCA)
13.4 Timer Function TMP89FM42
Timer start TA0CR TA0MOD Source clock mn Counter Write to TA0DRAL Write to TA0DRAH Temporary buffer (8 bits) TA0DRAL TA0DRAH INTTCA interrupt request 0 Write n Write m n n Match detection m Reflected by writing to TA0DRAH s s Match detection r 1 2 3 4 mn-1 0 1 2 3 Write s Write r rs-1 Counter clear rs 0 1 2
Timer stop
0
Counter clear
Reflected by writing to TA0DRAH When the double buffer is disabled (TA0MOD="0") Timer start TA0CR TA0MOD Source clock mn Counter Write to TA0DRAL Write to TA0DRAH Temporary buffer (8 bits) Double buffer (16 bits) TA0DRAL TA0DRAH INTTCA interrupt request 0 Write n Write m n mn n Match detection m Reflected at the same time as data is written into TA0DRAH while the timer is stopped Match detection r Reflected by an interrupt s rs s Match detection 1 2 3 4 mn-1 0 1 2 3 Write s Write r mn-1 Counter clear mn 0 1 rs-1 Counter clear rs 0 1
When the double buffer is enabled (TA0MOD="1")
Figure 13-2 Timer Mode Timing Chart
RA001
Page 150
TMP89FM42
Timer start TA0CR TA0MOD Source clock Counter
Timer stop
0000 0001 0002
18FD 18FE 18FF 1900 1901 1902 1903 1904 1905 1906 0000
TA0DRBL TA0DRBH Read TA0DRBL Read TA0DRBH Read Read value value 00H 00H
00 00
01
02
FD
FE 18
FF
00
01
02
03
04
05
06
00 00
TA0DRBH is updated when TA0DRBL is read
Read value FEH
Read value 18H
Read value 18H
Read Read value value 00H 00H
Figure 13-3 Timer Mode Timing Chart (Auto Capture)
RA001
Page 151
13. 16-bit Timer Counter (TCA)
13.4 Timer Function TMP89FM42
13.4.2 External trigger timer mode
In the external trigger timer mode, the up counter starts counting when it is triggered by the input to the TCA0 pin.
13.4.2.1 Setting
Setting the operation mode selection TA0MOD to "100" activates the external trigger timer mode. Select the source clock at TA0MOD. Select the trigger edge at the trigger edge input selection TA0MOD. Setting TA0MOD to "0" selects the rising edge, and setting it to "1" selects the falling edge. Note that this mode uses the TA0 input pin, and the TCA0 pin must be set to the input mode beforehand in port settings. The operation is started by setting TA0CR to "1". After the timer is started, writing to TA0MOD and TA0CR is disabled. Be sure to complete the required mode settings before starting the timer.
13.4.2.2 Operation
After the timer is started, when the selected trigger edge is input to the TCA0 pin, the up counter increments according to the selected source clock. When a match between the up counter value and the value set to timer register A (TA0DRA) is detected, an INTTA0 interrupt request is generated and the up counter is cleared to "0000H". After being cleared, the up counter continues counting. When TA0MOD is "1" and the edge opposite to the selected trigger edge is detected, the up counter stops counting and is cleared to "0000H". Subsequently, when the selected trigger edge is detected, the up counter restarts counting. In this mode, an interrupt request can be generated by detecting that the input pulse exceeds a certain pulse width. If TA0MOD is "0", the detection of the selected edge and the opposite edge is ignored during the period from the detection of the specified trigger edge and the start of counting through until the match detection. Setting TA0CR to "0" during the timer operation causes the up counter to stop counting and be cleared to "0000H".
13.4.2.3 Auto capture
Refer to "13.4.1.3 Auto capture".
13.4.2.4 Register buffer configuration
Refer to "13.4.1.4 Register buffer configuration".
RA001
Page 152
TMP89FM42
Timer start TA0CR TA0MOD TA0 pin input Source clock mn Counter Write to TA0DRAL Write to TA0DRAH TA0DRAL TA0DRAH INTTCA interrupt request 0 Write n Write m n Match detection m Reflected by writing to TA0DRAH 1 2 3 mn-1 0 Counter clear 1 2 3 Write s Write r s Match detection r rs-1 rs 0 1 2
Timer stop
Counting start
Edge is invalid during counting
Counting start
Edge is invalid during counting
0
Counter clear
Reflected by writing to TA0DRAH When the trigger is started (TA0MOD="0")
Timer start TA0CR TA0MOD TA0 pin input Source clock mn Counter Write to TA0DRAL Write to TA0DRAH TA0DRAL TA0DRAH INTTCA interrupt request 0 Write n Write m n Match detection m Reflected by writing to TA0DRAH 1 2 3 mn-1 0 Counter clear 1 2 0 Counter clear 1 Write s Write r s
Timer stop
Counting start
Counting start
Counting Counting stop start
rs rs-1 0 1 0 Counter clear
Match detection r
When the trigger is started and stopped (TA0MOD="1")
Reflected by writing to TA0DRAH
Figure 13-4 External Trigger Timer Timing Chart
RA001
Page 153
13. 16-bit Timer Counter (TCA)
13.4 Timer Function TMP89FM42
13.4.3 Event counter mode
In the event counter mode, the up counter counts up at the edge of the input to the TCA0 pin.
13.4.3.1 Setting
Setting the operation mode selection TA0MOD to "010" activates the event counter mode. Set the trigger edge at the external trigger input selection TA0MOD. Setting TA0MOD to "0" selects the rising edge, and setting it to "1" selects the falling edge for counting up. Note that this mode uses the TA0 input pin, and the TCA0 pin must be set to the input mode beforehand in port settings. The operation is started by setting TA0CR to "1". After the timer is started, writing to TA0MOD and TA0CR is disabled. Be sure to complete the required mode settings before starting the timer.
13.4.3.2 Operation
After the event counter mode is started, when the selected trigger edge is input to the TCA0 pin, the up counter increments. When a match between the up counter value and the value set to timer register A (TA0DRA) is detected, an INTTA0 interrupt request is generated and the up counter is cleared to "0000H". After being cleared, the up counter continues counting and counts up at each edge of the input to the TCA0 pin. Setting TA0CR to "0" during the operation causes the up counter to stop counting and be cleared to "0000H". The maximum frequency to be supplied is fcgck/2 [Hz] (in the NORMAL 1/2 or IDLE 1/2 mode) or fs/ 2 [Hz] (in the SLOW 1/2 or SLEEP 1 mode), and a pulse width of two machine cycles or more is required at both the "H" and "L" levels.
13.4.3.3 Auto capture
Refer to "13.4.1.3 Auto capture".
13.4.3.4 Register buffer configuration
Refer to "13.4.1.4 Register buffer configuration".
RA001
Page 154
TMP89FM42
Timer start TA0CR TA0 pin input mn Counter Write to TA0DRAL Write to TA0DRAH TA0DRAL TA0DRAH INTTCA interrupt request 0 Write n Write m n Match detection m Reflected by writing to TA0DRAH 1 2 3 4 mn-1 0 1 2 3 Write s Write r s Match detection r rs-1 Counter clear rs 0 1 2
Timer stop
0
Counter clear
Reflected by writing to TA0DRAH When the rising edge is selected (TA0MOD="0")
Figure 13-5 Event Count Mode Timing Chart
RA001
Page 155
13. 16-bit Timer Counter (TCA)
13.4 Timer Function TMP89FM42
13.4.4 Window mode
In the window mode, the up counter counts up at the rising edge of the pulse that is logical anded product of the input pulse to the TCA0 pin (window pulse) and the internal clock.
13.4.4.1 Setting
Setting the operation mode selection TA0MOD to "101" activates the window mode. Select the source clock at TA0MOD. Select the window pulse level at the trigger edge input selection TA0MOD. Setting TA0MOD to "0" enables counting up as long as the window pulse is at the "H" level. Setting TA0MOD to "1" enables counting up as long as the window pulse is at the "L" level. Note that this mode uses the TA0 input pin, and the TCA0 pin must be set to the input mode beforehand in port settings. The operation is started by setting TA0CR to "1". After the timer is started, writing to TA0MOD and TA0CR is disabled. Be sure to complete the required mode settings before starting the timer.
13.4.4.2 Operation
After the operation is started, when the level selected at TA0MOD is input to the TCA0 pin, the up counter increments according to the source clock selected at TA0MOD. When a match between the up counter value and the value set to timer register A (TA0DRA) is detected, an INTTA0 interrupt request is generated and the up counter is cleared to "0000H". After being cleared, the up counter restarts counting. The maximum frequency to be supplied must be slow enough for the program to analyze the count value. Define a frequency pulse that is sufficiently lower than the programmed internal source clock. Setting TA0CR to "0" during the timer operation causes the up counter to stop counting and be cleared to "0000H".
13.4.4.3 Auto capture
Refer to "13.4.1.3 Auto capture".
13.4.4.4 Register buffer configuration
Refer to "13.4.1.4 Register buffer configuration".
RA001
Page 156
TMP89FM42
Timer start TA0CR TA0MOD Count in the period of H level TA0 pin input Source clock mn Counter Write to TA0DRAL Write to TA0DRAH TA0DRAL TA0DRAH INTTCA interrupt request 0 Write n Write m n Match detection m Reflected by writing to TA0DRAH During the H-level counting (TA0MOD="0") 1 2 3 4 5 6 mn-1 0 1 2 3 4 5 6 Count in the period of H level
Timer stop
0
Counter clear
Figure 13-6 Window Mode Timing Chart
RA001
Page 157
13. 16-bit Timer Counter (TCA)
13.4 Timer Function TMP89FM42
13.4.5 Pulse width measurement mode
In the pulse width measurement mode, the up counter starts counting at the rising/falling edge(s) of the input to the TCA0 pin and measures the input pulse width based on the internal clock.
13.4.5.1 Setting
Setting the operation mode selection TA0MOD to "110" activates the pulse width measurement mode. Select the source clock at TA0MOD. Select the trigger edge at the trigger edge input selection TA0MOD. Setting TA0MOD to "0" selects the rising edge, and setting it to "1" selects the falling edge as a trigger to start the capture. The operation after capturing is determined by the pulse width measurement mode control TA0MOD. Setting TA0MOD to "0" selects the double-edge capture. Setting TA0MOD to "1" selects the single-edge capture. The operation to be executed in case of an overflow of the up counter can be selected at the overflow interrupt control TA0CR. Setting TA0OVE to "1" makes an INTTA0 interrupt request occur in case of an overflow. Setting TA0OVE to "0" makes no INTTA0 interrupt request occur in case of an overflow. Note that this mode uses the TA0 input pin, and the TCA0 pin must be set to the input mode beforehand in port settings. The operation is started by setting TA0CR to "1". After the timer is started, writing to TA0MOD and TA0CR is disabled. Be sure to complete the required mode settings before starting the timer.
13.4.5.2 Operation
After the timer is started, when the selected trigger edge (start edge) is input to the TCA0 pin, the up counter increments according to the selected source clock. Subsequently, when the edge opposite to the selected edge is detected, the up counter value is captured into TA0DRB, an INTTA0 interrupt request is generated, and TA0SR is set to "1". Depending on the TA0MOD setting, the operation differs as follows: * Double-edge capture (When TA0MOD is "0") The up counter continues counting up after the edge opposite to the selected edge is detected. Subsequently, when the selected trigger edge is input, the up counter value is captured into TA0DRA, an INTTA0 interrupt request is generated, and TA0SR is set to "1". At this time, the up counter is cleared to "0000H". * Single-edge capture (When TA0MOD is "1") The up counter stops counting up and is cleared to "0000H" when the edge opposite to the selected edge is detected. Subsequently, when the start edge is input, the up counter restarts increment.
When the up counter overflows during capturing, the overflow flag TA0SR is set to "1". At this time, an INTTA0 interrupt request occurs if the overflow interrupt control TA0CR is set to "1". The capture completion flags (TA0SR (TA0SR) are cleared to "0" automatically when TA0SR is read. RA001 Page 158 and the overflow flag
TMP89FM42
The captured value must be read from TA0DRB (and also from TA0DRA for the double-edge capture) before the next trigger edge is detected. If the captured value is not read, it becomes undefined. TA0DRA and TA0DRB must be read by using a 16-bit access instruction. Setting TA0CR to "0" during the timer operation causes the up counter to stop counting and be cleared to "0000H".
Note 1: After the timer is started, if the edge opposite to the selected trigger edge is detected first, no capture is executed and no INTTA0 interrupt request occurs. In this case, the capture starts when the selected trigger edge is detected next.
Timer start TA0CR TA0MOD TA0 pin input Count start Source clock mn Counter TA0DRBH, L INTTCA interrupt request 0 0 After the timer is started, if the falling edge is detected first, no interrupt occurs. Single-edge capture (TA0MOD="0") Timer start TA0CR TA0MOD TA0 pin input Count start Source clock st Counter TA0DRBH, L TA0DRAH, L INTTCA interrupt request 0 0 0 After the timer is started, if the falling edge is detected first, no interrupt occurs. Double-edge capture (TA0MOD="1") 1 2 3 4 mn-1 mn mn+1 mn st st-1 0 1 2 1 2 3 4 mn-1 0 Counter clear mn 1 2 3
Timer stop
0 Counter clear
Timer stop
0
Counter clear Counter clear
Figure 13-7 Pulse Width Measurement Mode Timing Chart
RA001
Page 159
13. 16-bit Timer Counter (TCA)
13.4 Timer Function TMP89FM42
13.4.6 Programmable pulse generate (PPG) mode
In the PPG output mode, an arbitrary duty pulse is output by two timer registers.
13.4.6.1 Setting
Setting the operation mode selection TA0MOD to "011" activates the PPG output mode. Select the source clock at TA0MOD. Select continuous or one-shot PPG output at TA0CR. Set the PPG output cycle at TA0DRA and set the time until the output is reversed first at TA0DRB. Be sure to set register values so that TA0DRA is larger than TA0DRB. Note that this mode uses the PPGA0 pin. the PPGA0 pin must be set to the output mode beforehand in port settings. Set the initial state of the PPGA0 pin at the timer flip-flop TA0CR. Setting TA0CR to "1" selects the "H" level as the initial state of the PPGA0 pin. Setting TA0CR to "0" selects the "L" level as the initial state of the PPGA0 pin. The operation is started by setting TA0CR to "1". After the timer is started, writing to TA0MOD and TA0CR is disabled. Be sure to complete the required mode settings before starting the timer.
13.4.6.2 Operation
after the timer is started, the up counter increments . When a match between the up counter value and the value set to timer register B (TA0DRB) is detected, the PPGA0 pin is changed to the "H" level if TA0CR is "0", or the PPGA0 pin is changed to the "L" level if TA0CR is "1". Subsequently, the up counter continues counting. When a match between the up counter value and the value set to timer register A (TA0DRA) is detected, the PPGA0 pin is changed to the "L" level if TA0CR is "0", or the PPGA0 pin is changed to the "H" level if TA0CR is "1". At this time, an INTTA0 interrupt request occurs. If the PPG output control TA0CR is set to "1" (one-shot), TA0CR is automatically cleared to "0" and the timer stops. If TA0CR is set to "0" (continuous), the up counter is cleared to "0000H" and continues counting and PPG output. When TA0CR is set to "0" (including the auto stop by the one-shot operation) during the PPG output, the PPGA0 pin returns to the level set in TA0CR. TA0CR can be changed during the operation. Changing TA0CR from "1" to "0" during the operation cancels the one-shot operation and enables the continuous operation. Changing TA0CR from "0" to "1" during the operation clears TA0CR to "0" and stops the timer automatically after the current pulse output is completed.
Timer registers A and B can be set to the double buffer. Setting TA0CR to "1" enables the double buffer. When the values set to TA0DRA and TA0DRB are changed during the PPG output with the double buffer enabled, the writing to TA0DRA and TA0DRB will not immediately become effective but will become effective when a match between TA0DRA and the up counter is detected. If the double buffer is disabled, the writing to TA0DRA and TA0DRB will become effective immediately. If the written value is smaller than the up counter value, the up counter overflows. After a cycle, the counter match process is executed to reverse the output.
RA001
Page 160
TMP89FM42
13.4.6.3 Register buffer configuration
(1) Temporary buffer The TMP89FM42 contains an 8-bit temporary buffer. When a write instruction is executed on TA0DRAL (TA0DRBL), the data is first stored into this temporary buffer, whether the double buffer is enabled or disabled. Subsequently, when a write instruction is executed on TA0DRAH (TA0DRBH), the set value is stored into the double buffer or TA0DRAH (TA0DRBH). At the same time, the set value in the temporary buffer is stored into the double buffer or TA0DRAL (TA0DRBL). (This structure is designed to enable the set values of the lower-level register and the higher-level register simultaneously.) Therefore, when setting data to TA0DRA (TA0DRB), be sure to write the data into TA0DRAL and TA0DRAH (TA0DRBL and TA0DRBH) in this order. See Figure 13-1 for the temporary buffer configuration.
(2)
Double buffer In the TMP89FM42, the double buffer can be used by setting TA0CR. Setting TA0CR to "0" disables the double buffer. Setting TA0CR to "1" enables the double buffer. See Figure 13-1 for the double buffer configuration. - When the double buffer is enabled When a write instruction is executed on TA0DRAH (TA0DRBH) during the timer operation, the set value is first stored into the double buffer, and TA0DRAH/L are not updated immediately. TA0DRAH/L (TA0DRBH/L) compare the last set values to the counter value. If a match is detected, an INTTCA0 interrupt request is generated and the double buffer set value is stored into TA0DRAH/L (TA0DRBH/L). Subsequently, the match detection is executed using a new set value. When a read instruction is executed on TA0DRAH/L (TA0DRBH/L), the double buffer value (the last set value) is read, not the TA0DRAH/L (TA0DRBH/L) values (the current effective values). When a write instruction is executed on TA0DRAH/L (TA0DRBH/L) while the timer is stopped, the set value is immediately stored into both the double buffer and TA0DRAH/L (TA0DRBH/L). - When the double buffer is disabled When a write instruction is executed on TA0DRAH (TA0DRBH) during the timer operation, the set value is immediately stored in TA0DRAH/L (TA0DRBH/L). Subsequently, the match detection is executed using a new set value. If the values set to TA0DRAH/L (TA0DRBH/L) are smaller than the up counter value, the up counter overflows and the match detection is executed using a new set value. As a result, the output pulse width may be longer than the set time. If that is a problem, enable the double buffer. When a write instruction is executed on TA0DRAH/L (TA0DRBH/L) while the timer is stopped, the set value is immediately stored into TA0DRAH/L (TA0DRBH/L).
RA001
Page 161
13. 16-bit Timer Counter (TCA)
13.4 Timer Function TMP89FM42
Timer start TA0CR TA0MOD Source clock n Counter Write to TA0DRAL, H Write to TA0DRBL, H TA0DRAL, H TA0DRBL, H PPG0 pin output INTTCA interrupt request Becomes the level set at TA0TFF when the timer is stopped m (Duty pulse) n (1 cycle) Reflected by an interrupt request r (Duty pulse) s (1 cycle) 0 Write n Write m n m Match detection 1 2 m m+1 0 1 2 r r+1 Counter clear s 0 1
Timer stop
r
r+1
0
Write s Write r Match detection
Counter clear
s r Match detection
Match detection Match detection
Returns to the level set at TA0TFF r (Duty pulse)
Continuous (TA0CR="0") Double buffer (TA0MOD="1")
Timer start TA0CR TA0MOD Source clock n Counter Write to TA0DRAL, H Write to TA0DRBL, H TA0DRAL, H TA0DRBL, H PPG0 pin output INTTCA interrupt request Becomes the level set at TA0TFF when the timer is stopped m (Duty pulse) n (1 cycle) 0 Write n Write m n m Match detection Match detection 1 2 m m+1
Timer stops automatically
0 Counter clear
Returns to the level set at TA0TFF
One-shot (TA0CR="1")
Figure 13-8 PPG Mode Timing Chart
RA001
Page 162
TMP89FM42
13.5 Noise Canceller
The digital noise canceller can be used in the operation modes that use the TCA0 pin.
13.5.1 Setting
When the digital noise canceller is used, the input level is sampled at the sampling intervals set at TA0CR. When the same level is detected three times consecutively, the level of the input to the timer is changed. Setting TA0CR to any values than "00" allows the noise canceller to start operation, regardless of the TA0CR value. When the noise canceller is used, allow the timer to start after a period of time that is equal to four times the sampling interval after TA0CR is set has elapsed. This stabilizes the input signal. Set TA0CR while the timer is stopped (TA0CR = "0"). When TA0CR is "1", writing is ignored. In the SLOW 1/2 or SLEEP 1 mode, setting TA0CR to "11" selects fs/2 as the source clock for the operation. Setting TA0CR to "00" disables the noise canceller. Setting TA0CR to "01" or "10" disables the TCA0 pin input.
Table 13-4 Noise Cancel Time ( fcgck = 10 [MHz] )
TA0NC 00 01 10 11 Sampling interval None 200 ns (2/fcgck) 400 ns (4/fcgck) 25.6 s (256/fcgck) Time removed as noise 600 ns or less 1.2 s or less 76.8 s or less Time regarded as signal 800 ns or more 1.6 s or more 102.4 s or more
RA001
Page 163
13. 16-bit Timer Counter (TCA)
13.6 Revision History TMP89FM42
13.6 Revision History
Rev RA001
Description "Table 13-3 Timer Mode Resolution and Maximum Time Setting" Revised Resolution and Maximum time of TA0MOD=11.
RA001
Page 164
TMP89FM42
14. 8-bit Timer Counter (TC0)
The TMP89FM42 contains 4 channels of high-performance 8-bit timer counters (TC0). Each timer can be used for time measurement and pulse output with a prescribed width. Two 8-bit timer counters are cascadable to form a 16-bit timer. This chapter describes 2 channels of 8-bit timer counters 00 and 01. For 8-bit timer counters 02 and 03, replace the SFR addresses and pin names as shown in Table 14-1 and Table 14-2. Table 14-1 SFR Address Assignment
16-bit mode T0xREG (Address) T00REG (0x0026) T01REG (0x0027) T02REG (0x0F88) T03REG (0x0F89) T0xPWM (Address) T00PWM (0x0028) T01PWM (0x0029) T02PWM (0x0F8A) T03PWM (0x0F8B) T0xMOD (Address) T00MOD (0x002A) T01MOD (0x002B) T02MOD (0x0F8C) T03MOD (0x0F8D) T0xxCR (Address) Low power consumption register
Timer counter 00
Lower
T001CR (0x002C)
POFFCR0
Timer counter 01
Higher
Timer counter 02
Lower
T023CR (0x0F8E)
POFFCR0
Timer counter 03
Higher
Table 14-2 Pin Names
Timer input pin Timer counter 00 Timer counter 01 Timer counter 02 Timer counter 03 TC00 pin TC01 pin TC02 pin TC03 pin PWM output pin
PWM0 pin PWM1 pin PWM2 pin PWM3 pin
PPG output pin
PPG0 pin PPG1 pin PPG2 pin PPG3 pin
RA002
Page 165
14. 8-bit Timer Counter (TC0)
TFF0
TCK0
EIN0
TCM0
DBE0
TCM1
DBE1
TCK1
EIN1
TFF1
TC00RUN
TCAS
TC01RUN
T01MOD
T001CR
TMP89FM42
Internal bus
OUTAND
RA002
Internal bus Reading and writing of T00PWM
Selector Selector Selector
Reading and writing of T00REG
Reading and writing of T01REG
Reading and writing of T01PWM
T00MOD 1
DBE1
Selector
14.1 Configuration
0
1
0
0
1
1
0
2
2
Double buffer Double buffer Double buffer
Double buffer
TC00 pin input 1
Selector Selector Selector Selector
S0 S1 0 T01REG T01PWM 0 1 1 0
0 T00PWM
1
T00REG
TFF0
16-bit PPG mode
F/F
PPG0 PWM0 pin output TFF1
F/F
fcgck/211 or fs/24 fcgck/210 or fs/23 fcgck/28 fcgck/26 fcgck/24 fcgck/22 fcgck/2 fc or fs/22
Comparator Comparator
I A B C D E F G H Y S
8/16-bit PPG mode
Y
TCAS 8-bit PPG mode Comparator Comparator TCAS
0 1
1 0
OUTAND
Y S
PPG1 PWM1 pin output Y
Figure 14-1 8-bit Timer Counters 00 and 01
1 0 S
Timer/event count modes 8-bit PWM mode 12-bit PWM mode Timer/event count modes 8-bit PWM mode 12-bit PWM mode Counter Overflow Counter
Page 166
8-bit up counter
Count up Clear Clear
TC01 pin input
INTT01 interrupt request INTT00 interrupt request
fcgck/211 or fs/24 fcgck/210 or fs/23 fcgck/28 fcgck/26 fcgck/24 fcgck/22 fcgck/2 fc or fs/22 1 0 S Y 8-bit up counter
Overflow
I A B C D E F G H
Y
Count up
S0 S1
2
TCAS
2
TMP89FM42
14.2 Control
14.2.1 Timer counter 00
The timer counter 00 is controlled by the timer counter 00 mode register (T00MOD) and two 8-bit timer registers (T00REG and T00PWM). Timer register 00
T00REG (0x0026) Bit Symbol Read/Write After reset 1 1 1 1 15 14 13 12 T00REG R/W 1 1 1 1 11 10 9 8
Timer register 00
T00PWM (0x0028) Bit Symbol Read/Write After reset 1 1 1 1 7 6 5 4 T00PWM R/W 1 1 1 1 3 2 1 0
Note 1: For the configuration of T00PWM in the 8-bit and 12-bit PWM modes, refer to "14.4.3 8-bit pulse width modulation (PWM) output mode" and "14.4.7 12-bit pulse width modulation (PWM) output mode".
RA002
Page 167
14. 8-bit Timer Counter (TC0)
TMP89FM42
Timer counter 00 mode register
T00MOD (0x002A) Bit Symbol Read/Write After reset 7 TFF0 R/W 1 6 DBE0 R/W 1 0 5 4 TCK0 R/W 0 0 3 2 EIN0 R/W 0 0 1 TCM0 R/W 0 0
TFF0
Timer F/F0 control
0 1 0 1
Clear Set Disable the double buffer Enable the double buffer NORMAL1/2 or IDLE1/2 mode SYSCR1 = "0" SYSCR1 = "1" fs/24 fs/23 fcgck/28 fcgck/26 fcgck/24 fcgck/2
2
DBE0
Double buffer control
SLOW1/2 or SLEEP1 mode fs/24 fs/23 fs/22
000 001 TCK0 Operation clock selection 010 011 100 101 110 111 Selection for using external source clock 0 1 00 01 TCM0 Operation mode selection 10 11
fcgck/211 fcgck/210 fcgck/28 fcgck/26 fcgck/24 fcgck/2
2
fcgck/2 fcgck
fcgck/2 fcgck
EIN0
Select the internal clock as the source clock. Select an external clock as the source clock. (the falling edge of the TC00 pin) 8-bit timer/event counter modes 8-bit timer/event counter modes 8-bit pulse width modulation output (PWM) mode 8-bit programmable pulse generate (PPG) mode
Note 1: fcgck: Gear clock [Hz], fs: Low-frequency clock [Hz] Note 2: Set T00MOD while the timer is stopped. Writing data into T00MOD is invalid during the timer operation. Note 3: In the 8-bit timer/event modes, the TFF0 setting is invalid. In this mode, when the PWM0 and PPG0 pins are set as the function output pins in the port setting, the pins always output the "H" level. Note 4: When EIN0 is set to "1" and the external clock input is selected as the source clock, the TCK0 setting is ignored. Note 5: When the T001CR bit is "1", timer 00 operates in the 16-bit mode. The T00MOD setting is invalid and timer 00 cannot be used independently in this mode. When the PWM0 and PPG0 pins are set to the function output pins in the port setting, the pins always output the "H" level. Note 6: When the 16-bit mode is selected at T001CR, the timer start is controlled at T001CR. Timer 00 is not started by writing data into T001CR.
RA002
Page 168
TMP89FM42
14.2.2 Timer counter 01
Timer counter 01 is controlled by timer counter 01 mode register (T01MOD) and two 8-bit timer registers (T01REG and T01PWM). Timer register 01
T01REG (0x0027) Bit Symbol Read/Write After reset 1 1 1 1 15 14 13 12 T01REG R/W 1 1 1 1 11 10 9 8
Timer register 01
T01PWM (0x0029) Bit Symbol Read/Write After reset 1 1 1 1 7 6 5 4 T01PWM R/W 1 1 1 1 3 2 1 0
Note 1: For the configuration of T00PWM in the 8-bit and 12-bit PWM modes, refer to "14.4.3 8-bit pulse width modulation (PWM) output mode" and "14.4.7 12-bit pulse width modulation (PWM) output mode".
RA002
Page 169
14. 8-bit Timer Counter (TC0)
TMP89FM42
Timer counter 01 mode register
T01MOD (0x002B) Bit Symbol Read/Write After reset 7 TFF1 R/W 1 6 DBE1 R/W 1 0 5 4 TCK1 R/W 0 0 3 2 EIN1 R/W 0 0 1 TCM1 R/W 0 0
TFF1
Timer F/F1 control
0 1 0 1
Clear Set Disable the double buffer Enable the double buffer NORMAL1/2 or IDLE1/2 mode SYSCR1 = "0" SYSCR1 = "1" fs/24 fs/23 fcgck/28 fcgck/26 fcgck/24 fcgck/2
2
DBE1
Double buffer control
SLOW1/2 or SLEEP1 mode fs/24 fs/23 fs/22
000 001 TCK1 Operation clock selection 010 011 100 101 110 111 Selection for using external source clock 0 1
fcgck/211 fcgck/210 fcgck/28 fcgck/26 fcgck/24 fcgck/2
2
fcgck/2 fcgck
fcgck/2 fcgck
EIN1
Select the internal clock as the source clock. Select an external clock as the source clock. (the falling edge of the TC01 pin) T001CR="0" (8-bit mode) T001CR="1" (16-bit mode) 16-bit timer/event counter modes
00
8-bit timer/event counter modes
TCM1
Operation mode selection
01
8-bit timer/event counter modes 8-bit pulse width modulation output (PWM) mode 8-bit programmable pulse generate (PPG) mode
16-bit timer/event counter modes 12-bit pulse width modulation output (PWM) mode 16-bit programmable pulse generate (PPG) mode
10
11
Note 1: fcgck: Gear clock [Hz], fs: Low-frequency clock [Hz] Note 2: Set T01MOD while the timer is stopped. Writing data into T01MOD is invalid during the timer operation. Note 3: In the 8-bit timer/event modes, the TFF1 setting is invalid. In this mode, when the PWM1 and PPG1 pins are set as the function output pins in the port setting, the pins always output the "H" level. Note 4: When EIN1 is set to "1" and the external clock input is selected as the source clock, the TCK1 setting is ignored.
RA002
Page 170
TMP89FM42
14.2.3 Common to timer counters 00 and 01
Timer counters 00 and 01 have the low power consumption register (POFFCR0) and timer 00 and 01 control registers in common. Low power consumption register 0
POFFCR0 (0x0F74) Bit Symbol Read/Write After reset 7 R/W 0 6 R/W 0 5 TC023EN R/W 0 4 TC001EN R/W 0 3 R/W 0 2 R/W 0 1 TCA1EN R/W 0 0 TCA0EN R/W 0
TC023EN
TC02,03 control
0 1 0 1 0 1 0 1
Disable Enable Disable Enable Disable Enable Disable Enable
TC001EN
TC00,01 control
TCA1EN
TCA1 control
TCA0EN
TCA0 control
RA002
Page 171
14. 8-bit Timer Counter (TC0)
TMP89FM42
Timer counter 01 control register
T001CR (0x002C) Bit Symbol Read/Write After reset 7 R 0 6 R 0 5 R 0 4 R 0 3 OUTAND R/W 0 2 TCAS R/W 0 1 T01RUN R/W 0 0 T00RUN R/W 0
0 OUTAND Timers 00 and 01 output control 1
Output the timer 00 output from the PWM0 and PPG0 pins and the timer 01 output from the PWM1 and PPG1 pins. Output a pulse that is a logical ANDed product of the outputs of timers 00 and 01 from the PWM1 and PPG1 pins. Use timers 00 and 01 independently (8-bit mode). Cascade timers 00 and 01 (16-bit mode). Stop and clear the counter Start Stop and clear the counter Start
TCAS
Timers 00 and 01 cascade control Timer 01 control Timers 00/01 control (16-bit mode) Timer 00 control
0 1 0 1 0 1
T01RUN
T00RUN
Note 1: When STOP mode is started, T00RUN and T01RUN are cleared to "0" and the timers stop. Set T001CR again to use timers 00 and 01 after STOP mode is released. Note 2: When a read instruction is executed on T001CR, bits 7 to 4 are read as "0". Note 3: When OUTAND is "1", output is obtained from the PWM1 and PPG1 pins only. There is no timer output to the PWM0 and PPG0 pins. If the PWM0 and PPG0 pins are set as the function output pins in the port setting, the pins always output "H". Note 4: OUTAND and TCAS can be changed only when both TC01RUN and TC00RUN are "0". When either TC01RUN or TC00RUN is "1" or both are "1", the register values remain unchanged by executing write instructions on OUTAND and TCAS. OUTAND and TCAS can be changed at the same time as TC01RUN and TC00RUN are changed from "0" to "1".
RA002
Page 172
TMP89FM42
14.2.4 Operation modes and usable source clocks
The operations modes of the 8-bit timers and the usable source clocks are listed below. Table 14-3 Operation Modes and Usable Source Clocks (NORMAL1/2 and IDLE1/2 modes)
TCK0 000 fcgck/2 or fs/24 8-bit timer modes 8-bit timer 8-bit event counter 8-bit PWM 8-bit PPG 16-bit timer modes 16-bit timer 16-bit event counter 12-bit PWM 16-bit PPG
11
001 fcgck/2 or fs/23
10
010
011
100
101
110
111 TC0i pin input
Operation mode
fcgck/2
8
fcgck/2
6
fcgck/2
4
fcgck/2
2
fcgck/2
fcgck







Note 1: : Usable, -: Unusable Note 2: Set the source clock in the 16-bit modes on the TC01 side (TCK1). Note 3: When the low-frequency clock, fs, is not oscillating, it must not be selected as the source clock. If fs is selected when it is not oscillating, no source clock is supplied to the timer, and the timer remains stopped. Note 4: i=0, 1 (i=0 only in the 16-bit modes) Note 5: The operation modes of the 8-bit timers and the usable source clocks are listed below.
Table 14-4 Operation Modes and Usable Source Clocks (SLOW1/2 and SLEEP1 modes)
TCK0 Operation mode 8-bit timer modes 8-bit timer 8-bit event counter 8-bit PWM 8-bit PPG 16-bit timer modes 16-bit timer 16-bit event counter 12-bit PWM 16-bit PPG 000 fs/2
4
001 fs/2
3
010 -
011 -
100 -
101 -
110 -
111 fs/22
TC0i pin input
Note 1: : Usable, -: Unusable Note 2: Set the source clock in the 16-bit modes on the TC01 side (TCK1). Note 3: i=0, 1 (i=0 only in the 16-bit modes)
RA002
Page 173
14. 8-bit Timer Counter (TC0)
TMP89FM42
14.3 Low Power Consumption Function
Timer counters 00 and 01 have the low power consumption registers (POFFCR0) that save power when the timers are not used. Setting POFFCR0 to "0" disables the basic clock supply to timer counters 00 and 01 to save power. Note that this renders the timers unusable. Setting POFFCR0 to "1" enables the basic clock supply to timer counters 00 and 01 and allows the timers to operate. After reset, POFFCR0 are initialized to "0", and this makes the timers unusable. When using the timers for the first time, be sure to set POFFCR0 to "1" in the initial setting of the program (before the timer control registers are operated). Do not change POFFCR0 to "0" during the timer operation. Otherwise timer counters 00 and 01 may operate unexpectedly.
RA002
Page 174
TMP89FM42
14.4 Functions
Timer counters TC00 and TC01 have 8-bit modes in which they are used independently and 16-bit modes in which they are cascaded. The 8-bit modes include four operation modes; the 8-bit timer mode, the 8-bit event counter mode, the 8-bit pulse width modulation output (PWM) mode and the 8-bit programmable pulse generated output (PPG) mode. The 16-bit modes include four operation modes; the 16-bit timer mode, the 16-bit event counter mode, the 12-bit PWM mode and the 16-bit PPG mode.
14.4.1 8-bit timer mode
In the 8-bit timer mode, the up-counter counts up using the internal clock, and interrupts can be generated regularly at specified times. The operation of TC00 is described below, and the same applies to the operation of TC01. (Replace TC00- by TC01-).
14.4.1.1 Setting
TC00 is put into the 8-bit timer mode by setting T00MOD to "00" or "01", T001CR to "0" and T00MOD to "0". Select the source clock at T00MOD. Set the count value to be used for the match detection as an 8-bit value at the timer register T00REG. Set T00MOD to "1" to use the double buffer. Setting T001CR to "1" starts the operation. After the timer is started, writing to T00MOD becomes invalid. Be sure to complete the required mode settings before starting the timer.
14.4.1.2 Operation
Setting T001CR to "1" allows the 8-bit up counter to increment based on the selected internal source clock. When a match between the up counter value and the T00REG set value is detected, an INTT00 interrupt request is generated and the up counter is cleared to "0x00". After being cleared, the up counter restarts counting. Setting T001CR to "0" during the timer operation makes the up counter stop counting and be cleared to "0x00".
14.4.1.3 Double buffer
The double buffer can be used for T00REG by setting T00MOD. The double buffer is disabled by setting T00MOD to "0" or enabled by setting T00MOD to "1". * When the double buffer is enabled When a write instruction is executed on T00REG during the timer operation, the set value is initially stored in the double buffer, and T00REG is not immediately updated. T00REG compares the previous set value with the up counter value. When the values match, an INTT00 interrupt request is generated and the double buffer set value is stored in T00REG. Subsequently, the match detection is executed using a new set value. When a write instruction is executed on T00REG while the timer is stopped, the set value is immediately stored in both the double buffer and T00REG. * When the double buffer is disabled When a write instruction is executed on T00REG during the timer operation, the set value is immediately stored in T00REG. Subsequently, the match detection is executed using a new set value.
RA002
Page 175
14. 8-bit Timer Counter (TC0)
TMP89FM42
If the value set to T00REG is smaller than the up counter value, the match detection is executed using a new set value after the up counter overflows. Therefore, the interrupt request interval may be longer than the selected time. If the value set to T00REG is equal to the up counter value, the match detection is executed immediately after data is written into T00REG. Therefore, the interrupt request interval may not be an integral multiple of the source clock (Figure 14-3). If these are problems, enable the double buffer. When a write instruction is executed on T00REG while the timer is stopped, the set value is immediately stored in T00REG.
When a read instruction is executed on T00REG, the last value written into T00REG is read out, regardless of the T00MOD setting. Table 14-5 8-bit Timer Mode Resolution and Maximum Time Setting
Source clock [Hz] T00MOD NORMAL1/2 or IDLE1/2 mode SYSCR1 = "0" fcgck/211 fcgck/210 fcgck/28 fcgck/26 fcgck/24 fcgck/22 fcgck/2 fcgck SYSCR1 = "1" fs/24 fs/23 fcgck/28 fcgck/26 fcgck/24 fcgck/22 fcgck/2 fcgck SLOW1/2 or SLEEP1 mode fcgck=10MHz fs=32.768KHz fcgck=10MHz fs=32.768KHz Resolution Maximum time setting
000 001 010 011 100 101 110 111
fs/24 fs/23 fs/22
204.8s 102.4s 25.6s 6.4s 1.6s 400ns 200ns 100ns
488.2s 244.1s 122.1s
52.2ms 26.1ms 6.5ms 1.6ms 408s 102s 51s 25.5s
124.5ms 62.3ms 31.1ms
(Example) Operate TC00 in the 8-bit timer mode with the operation clock of fcgck/22 [Hz] and generate interrupts at 64 s intervals
(fcgck = 10 MHz)
LD DI SET EI LD LD SET
(POFFCR0),0x10 (EIRH).4 (T00MOD),0xE8 (T00REG),0xA0 (T001CR).0
; Sets TC001EN to "1" ; Sets the interrupt master enable flag to "disable" ; Sets the INTTC00 interrupt enable register to "1" ; Sets the interrupt master enable flag to "enable" ; Selects the 8-bit timer mode and fcgck/22 ; Sets the timer register (64s / (22/fcgck) = 0xA0) ; Starts TC00
RA002
Page 176
TMP89FM42
Timer start T001CR T00MOD Source clock m Counter Write to T00REG T00REG INTT00 interrupt request 0 Write m Match detection m Reflected by writing to T00REG 1 2 3 4 m-1 0 1 2 3 Write n Match detection n n-1 Counter clear n 0 1 2
Timer stop
0
Counter clear
Reflected by writing to T00REG When the double buffer is disabled (T00MOD="0") Timer start T001CR T00MOD Source clock m Counter Write to T00REG Double buffer T00REG INTT00 interrupt request 0 Write m m Match detection m Reflected at the same time as data is written into T00REG while the timer is stopped 1 2 3 4 m-1 0 1 2 3 Write n n Match detection n Match detection Reflected by an interrupt m-1 Counter clear m 0 1 n-1 Counter clear n 0 1
When the double buffer is enabled (T00MOD="1")
Figure 14-2 Timer Mode Timing Chart
T00MOD
Source clock Counter Write to T00REG T00REG n-5 n-4 n-3 Write n-2 n Match detection n-2 n-2 0 Counter clear 1 2
INTT00 interrupt request
Figure 14-3 Operation When T00REG and the Up Counter Have the Same Value
RA002
Page 177
14. 8-bit Timer Counter (TC0)
TMP89FM42
14.4.2 8-bit event counter mode
In the 8-bit event counter mode, the up counter counts up at the falling edge of the input to the TC00 or TC01 pin. The operation of TC00 is described below, and the same applies to the operation of TC01.
14.4.2.1 Setting
TC00 is put into the 8-bit event counter mode by setting T00MOD to "00", T001CR to "0" and T00MOD to "1". Set the count value to be used for the match detection as an 8-bit value at the timer register T00REG. Set T00MOD to "1" to use the double buffer. Setting T001CR to "1" starts the operation. After the timer is started, writing to T00MOD becomes invalid. Be sure to complete the required mode settings before starting the timer.
14.4.2.2 Operation
Setting T001CR to "1" allows the 8-bit up counter to increment at the falling edge of the TC00 pin. When a match between the up-counter value and the T00REG set value is detected, an INTT00 interrupt request is generated and the up counter is cleared to "0x00". After being cleared, the up counter restarts counting. Setting T001CR to "0" during the timer operation makes the up counter stop counting and be cleared to "0x00". The maximum frequency to be supplied is fcgck/22 [Hz] (in NORMAL1/2 or IDLE1/2 mode) or fs/24 [Hz] (in SLOW1/2 or SLEEP1 mode), and a pulse width of two machine cycles or more is required at both the "H" and "L" levels.
14.4.2.3 Double buffer
Refer to "14.4.1.3 Double buffer".
(Example) Operate TC00 in the 8-bit event counter mode and generate an interrupt each time 16 falling edges are detected at the
TC00 pin.
LD DI SET EI LD LD SET
(POFFCR0),0x10 (EIRH).4 (T00MOD),0xC4 (T00REG),0x10 (T001CR).0
; Sets TC001EN to "1" ; Sets the interrupt master enable flag to "disable" ; Sets the INTTC00 interrupt enable register to "1" ; Sets the interrupt master enable flag to "enable" ; Selects to the 8-bit event counter mode ; Sets the timer register ; Starts TC00
RA002
Page 178
TMP89FM42
Timer start T001CR TC00 pin input m Counter Write to T00REG T00REG INTT00 interrupt request 0 Write m Match detection m Reflected by writing to T00REG 1 2 3 4 m-1 0 1 2 3 Write n Match detection n n-1 Counter clear n 0 1 2
Timer stop
0
Counter clear
Reflected by writing to T00REG When the double buffer is disabled (T00MOD="0")
Figure 14-4 Event Counter Mode Timing Chart
RA002
Page 179
14. 8-bit Timer Counter (TC0)
TMP89FM42
14.4.3 8-bit pulse width modulation (PWM) output mode
The pulse-width modulated pulses with a resolution of 7 bits are output in the 8-bit PWM mode. An additional pulse can be added to the 2 x n-th duty pulse. This enables PWM output with a resolution nearly equivalent to 8 bits. (n=1, 2, 3...) The operation of TC00 is described below, and the same applies to the operation of TC01.
14.4.3.1 Setting
TC00 is put into the 8-bit PWM mode by setting T00MOD to "10" and T001CR to "0". Set T00MOD to "0" and select the clock at T00MOD. Set the count value to be used for the match detection and the additional pulse value at the PWM register T00PWM. Set T00MOD to "1" to use the double buffer. Setting T001CR to "1" starts the operation. After the timer is started, writing to T00MOD becomes invalid. Be sure to complete the required mode settings before starting the timer. In the 8-bit PWM mode, the T00PWM register is configured as follows: Timer register 00
T00PWM (0x0028) Bit Symbol Read/Write After reset R/W 1 R/W 1 R/W 1 7 6 5 4 PWMDUTY R/W 1 R/W 1 R/W 1 R/W 1 3 2 1 0 PWMAD R/W 1
Timer register 01
T01PWM (0x0029) Bit Symbol Read/Write After reset R/W 1 R/W 1 R/W 1 7 6 5 4 PWMDUTY R/W 1 R/W 1 R/W 1 R/W 1 3 2 1 0 PWMAD R/W 1
PWMDUTY is a 7-bit register used to set the duty pulse width value (the time before the first output change) in a cycle (128 counts of the source clock). PWMAD is a register used to set the additional pulse. When PWMAD is "1", an additional pulse that corresponds to 1 count of the source clock is added to the 2 x n-th duty pulse (n=1, 2, 3...). In other words, the 2 x n-th duty pulse has the output of PWMDUTY+1. The additional pulse is not added when PWMAD is "0".
RA002
Page 180
TMP89FM42
Timer start (Duty pulse width) T00PWM PWM0 pin output (TFF0="1")
Additional pulse (Duty pulse width) T00PWM
Additional pulse
Additional pulse
PWM0 pin output (TFF0="0") 128 counts (cycle width) INTT00 interrupt request Cycle 1 Cycle 2 Cycle 3 Cycle 4 Cycle 5 Cycle 6 128 counts (cycle width)
Figure 14-5 PWM0 Pulse Output
Set the initial state of the PWM0 pin at T00MOD. Setting T00MOD to "0" selects the "L" level as the initial state of the PWM0 pin. Setting T00MOD to "1" selects the "H" level as the initial state of the PWM0 pin. If the PWM0 pin is set as the function output pin in the port setting while the timer is stopped, the value of T00MOD is output to the PWM0 pin. Table 14-6 shows the list of output levels of the PWM0 pin. Table 14-6 List of Output Levels of PWM0 Pin
PWM0 pin output level
TFF0
Before the start of operation (initial state)
T00PWM matched (after the additional pulse) H L
Overflow
Operation stopped (initial state)
0 1
L H
L H
L H
And by setting "1" to T001CR bit, a logical product (AND) pulse of TC00 and TC01's output can be output to PWM0 pin. By using this function, the remote-control waveform can be created eaily.
14.4.3.2 Operations
Setting T001CR to "1" allows the up counter to increment based on the selected source clock. When a match between the lower 7 bits of the up counter value and the value set to T00PWM is detected, the output of the PWM0 pin is reversed. When T00MOD is "0", the PWM0 pin changes from the "L" to "H" level. When T00MOD is "1", the PWM0 pin changes from the "H" to "L" level. If T00PWM is "1", an additional pulse that corresponds to 1 count of the source clock is added at the 2 x n-th match detection (n=1, 2, 3...). In other words, the PWM0 pin output is reversed at the timing of T00PWM+1. When T00MOD is "0", the period of the "L" level becomes longer than the value set to T00 by 1 source clock. When T00MOD is "1", the period of the "H" level becomes longer than the value set to T00PWM by 1 source clock. This function allows two cycles of output pulses to be handled with a resolution nearly equivalent to 8 bits. No additional pulse is inserted when T00PWM is "0".
RA002
Page 181
14. 8-bit Timer Counter (TC0)
TMP89FM42
Subsequently, the up counter continues counting up. When the up counter value reaches 128, an overflow occurs and the up counter is cleared to "0x00". At the same time, the output of the PWM0 pin is reversed. When T00MOD is "0", the PWM0 pin changes from the "H" to "L" level. When T00MOD is "1", the PWM0 pin changes from the "L" to "H" level. If the 2 x n-th overflow occurs at this time, an INTT00 interrupt request is generated. (No interrupt request is generated at the 2 x n-th -1 overflow.) Subsequently, the up counter continues counting up. When T001CR is set to "0" during the timer operation, the up counter is stopped and cleared to "0x00". The PWM0 pin returns to the level selected at T00MOD.
(Example) Operate TC00 in the 8-bit PWM mode with the operation clock of fcgck/2 and output a duty pulse nearly equivalent to 11.6
s (fcgck = 10 MHz) (Actually, output a total duty pulse of 23.2 s in 2 cycles (102.4 s))
SET SET LD DI SET EI LD LD SET
(P7FC).0 (P7CR).0 (POFFCR0),0x10 (EIRH).4 (T00MOD),0xF2 (T00PWM),0x73 (T001CR).0
; Sets P7FC0 to "1" ; Sets P7CR0 to "1" ; Sets TC001EN to "1" ; Sets the interrupt master enable flag to "disable" ; Sets the INTTC00 interrupt enable register to "1" ; Sets the interrupt master enable flag to "enable" ; Selects the 8-bit PWM mode and fcgck/2 ; Sets the timer register (duty pulse) ; (11.6s x 2) / (2/fcgck) = 0x73 ; Starts TC00
Timer start T001CR T00MOD Source clock Overflow 128 01 Counter clear Write to T00PWM Double buffer T00PWM T00PWM PWM0 pin output Becomes the level selected at TFF0 while the timer is stopped INTT00 interrupt request m (Duty pulse) 128 counts (Cycle 1) m Match detection Match detection Write m m Write r r Overflow 128 01 Overflow 128 01 Counter clear
Timer stop
Counter
0
1
m m+1
m m+1
r
r+1
r
r+1
128 01
0
Counter clear Write s s Reflected by an interrupt request r Match detection
Counter clear
Reflected by an interrupt request Match detection s
Additional pulse No interrupt request is generated m (Duty pulse) 128 counts (Cycle 2) Interrupt request r (Duty pulse) 128 counts (Cycle 3) No interrupt request is generated r+1 (Duty pulse) 128 counts (Cycle 4)
Returns to the level selected at TFF0
When the double buffer is enabled (T00MOD="1")
Figure 14-6 8-bit PWM Mode Timing Chart
RA002
Page 182
TMP89FM42
14.4.3.3 Double buffer
The double buffer can be used for T00PWM by setting T00MOD. The double buffer is disabled by setting T00MOD to "0" or enabled by setting T00MOD to "1". * When the double buffer is enabled When a write instruction is executed on T00PWM during the timer operation, the set value is first stored in the double buffer, and T00PWM is not updated immediately. T00PWM compares the previous set value with the up counter value. When the 2 x n-th overflow occurs, an INTT00 interrupt request is generated and the double buffer set value is stored in T00PWM. Subsequently, the match detection is executed using a new set value. When a read instruction is executed on T00PWM, the value in the double buffer (the last set value) is read out, not the T00PWM value (the currently effective value). When a write instruction is executed on T00PWM while the timer is stopped, the set value is immediately stored in both the double buffer and T00PWM. * When the double buffer is disabled When a write instruction is executed on T00PWM during the timer operation, the set value is immediately stored in T00PWM. Subsequently, the match detection is executed using a new set value. If the value set to T00PWM is smaller than the up counter value, the PWM0 pin is not reversed until the up counter overflows and a match detection is executed using a new set value. If the value set to T00PWM is equal to the up counter value, the match detection is executed immediately after data is written into T00PWM. Therefore, the timing of changing the PWM0 pin may not be an integral multiple of the source clock (Figure 14-7). Similarly, if T00PWM is set during the additional pulse output, the timing of changing the PWM0 pin may not be an integral multiple of the source clock. If these are problems, enable the double buffer. When a write instruction is executed on T00PWM while the timer is stopped, the set value is immediately stored in T00PWM.
T00MOD
Source clock Counter Write to T00PWM T00PWM PWM0 pin output n-5 n-4 n-3 Write n-2 n Match detection n-2 n-2 n-1 n
Figure 14-7 Operation When T00PWM and the Up Counter Have the Same Value
RA002
Page 183
14. 8-bit Timer Counter (TC0)
TMP89FM42
Table 14-7 Resolutions and Cycles in the 8-bit PWM Mode
Source clock [Hz] T00MOD NORMAL1/2 or IDLE1/2 mode SYSCR1 = "0" 000 fcgck/211 SYSCR1 = "1" fs/24 SLOW1/2 or SLEEP1 mode fcgck=10MHz fs=32.768KHz fcgck=10MHz fs=32.768KHz Resolution 7-bit cycle (period x 2)
fs/24
204.8s
488.2s
26.2ms (52.4ms) 13.1ms (26.2ms) 3.3ms (6.6ms) 819.2s (1638.4s) 204.8s (409.6s) 51.2s (102.4s) 25.6s (51.2s) 12.8s (25.6s)
62.5ms (125ms) 31.3ms (62.5ms) -
001
fcgck/210
fs/23
fs/23
102.4s
244.1s
010
fcgck/28
fcgck/28
-
25.6s
-
011
fcgck/26
fcgck/26
-
6.4s
-
-
100
fcgck/24
fcgck/24
-
1.6s
-
-
101
fcgck/22
fcgck/22
-
400ns
-
-
110
fcgck/2
fcgck/2
-
200ns
-
15.6ms (31.3ms)
111
fcgck
fcgck
fs/22
100ns
122.1s
RA002
Page 184
TMP89FM42
14.4.4 8-bit programmable pulse generate (PPG) output mode
In the 8-bit PPG mode, the pulses with arbitrary duty and cycle are output by using the T00REG and T00PWM registers. By setting the T001CR register, a pulse that is a logical ANDed product of the TC00 and TC01 outputs can be output to the TC01 pin. This function facilitates the generation of remote-controlled waveforms, for example. The operation of TC00 is described below, and the same applies to the operation of TC01.
14.4.4.1 Setting
TC00 is put into the 8-bit PPG mode by setting T00MOD to "10" and T001CR to "0". Set T00MOD to "0" and select the clock at T00MOD. Set the duty pulse width at T00PWM and the cycle width at T00REG. Set T00MOD to "1" to use the double buffer. Setting T001CR to "1" starts the operation. After the timer is started, writing to T00MOD becomes invalid. Be sure to complete the required mode settings before starting the timer.
Timer start Timer stop
(Duty pulse) T00PWM PPG0 pin output (TFF0="0") PPG0 pin output (TFF0="1") T00REG (1 cycle)
(Duty pulse) T00PWM
T00REG (1 cycle)
Figure 14-8 PPG0 Pulse Output
Set the initial state of the PPG0 pin at T00MOD. Setting T00MOD to "0" selects the "L" level as the initial state of the PPG0 pin. Setting T00MOD to "1" selects the "H" level as the initial state of the PPG0 pin. If the PPG0 pin is set as the function output pin in the port setting while the timer is stopped, the value of T00MOD is output to the PPG0 pin. Table 14-8 shows the list of output levels of the PPG0 pin. Table 14-8 List of Output Levels of PPG0 Pin
PPG0 pin output level
TFF0
Before the start of operation (initial state) L H
T00PWM matched H L
T00REG matched L H
Operation stopped (initial state) L H
0 1
Setting the T001CR bit to "1" allows the PPG0 pin to output a pulse that is a logical ANDed product of the TC00 and TC01 outputs.
RA002
Page 185
14. 8-bit Timer Counter (TC0)
TMP89FM42
14.4.4.2 Operation
Setting T001CR to "1" allows the up counter to increment based on the selected source clock. When a match between the internal up counter value and the value set to T00PWM is detected, the output of the PPG0 pin is reversed. When T00MOD is "0", the PPG0 pin changes from the "L" to "H" level. When T00MOD is "1", the PPG0 pin changes from the "H" to "L" level. Subsequently, the up counter continues counting up. When a match between the up counter value and T00REG is detected, the output of the PPG0 pin is reversed again. When T00MOD is "0", the PPG0 pin changes from the "H" to "L" level. When T00MOD is "1", the PPG0 pin changes from the "L" to "H" level. At this time, an INTT00 interrupt request is generated. When T001CR is set to "0" during the operation, the up counter is stopped and cleared to "0x00". The PPG0 pin returns to the level selected at T00MOD.
14.4.4.3 Double buffer
The double buffer can be used for T00PWM and T00REG by setting T00MOD. The double buffer is disabled by setting T00MOD to "0" or enabled by setting T00MOD to "1". * When the double buffer is enabled When a write instruction is executed on T00PWM (T00REG) during the timer operation, the set value is first stored in the double buffer, and T00PWM (T00REG) is not updated immediately. T00PWM (T00REG) compares the previous set value with the up counter value. When an INTT00 interrupt request is generated, the double buffer set value is stored in T00PWM (T00REG). Subsequently, the match detection is executed using a new set value. When a read instruction is executed on T00PWM (T00REG), the value in the double buffer (the last set value) is read out, not the T00PWM (T00REG) value (the currently effective value). When a write instruction is executed on T00PWM (T00REG) while the timer is stopped, the set value is immediately stored in both the double buffer and T00PWM (T00REG). * When the double buffer is disabled When a write instruction is executed on T00PWM (T00REG) during the timer operation, the set value is immediately stored in T00PWM (T00REG). Subsequently, the match detection is executed using a new set value. If the value set to T00PWM (T00REG) is smaller than the up counter value, the PPG0 pin is not reversed until the up counter overflows and a match detection is executed using a new set value. If the value set to T00PWM (T00REG) is equal to the up counter value, the match detection is executed immediately after data is written into T00PWM (T00REG). Therefore, the timing of changing the PPG0 pin may not be an integral multiple of the source clock (Figure 14-10). If these are problems, enable the double buffer. When a write instruction is executed on T00PWM (T00REG) while the timer is stopped, the set value is immediately stored in T00PWM (T00REG).
(Example)
Operate TC00 in the 8-bit PPG mode with the operation clock of fcgck/2 and output the 8s duty pulse in 32s cycles (fcgck = 10 MHz)
SET SET LD DI SET EI LD LD
(P7FC).0 (P7CR).0 (POFFCR0),0x10 (EIRH).4 (T00MOD),0xF3 (T00REG),0xA0
; Sets P7FC0 to "1" ; Sets P7CR0 to "1" ; Sets TC001EN to "1" ; Sets the interrupt master enable flag to "disable" ; Sets the INTTC00 interrupt enable register to "1" ; Sets the interrupt master enable flag to "enable" ; Selects the 8-bit PPG mode and fcgck/2 ; Sets the timer register (cycle) ; 32s / (2/fcgck) = 0xA0
RA002
Page 186
TMP89FM42
LD SET
(T00PWM),0x28 (T001CR).0
; Sets the timer register (duty pulse) ; 8s / (2/fcgck) = 0x28 ; Starts TC00
Timer start T001CR T00MOD Source clock p Counter 0 1 m m+1 01 Counter clear Write to T00PWM Double buffer T00PWM Write to T00REG Double buffer T00REG PPG0 pin output INTT00 interrupt request Becomes the level selected at TFF0 while the timer is stopped m (Duty pulse) p (1 cycle) r (Duty pulse) s (1 cycle) r (Duty pulse) s (1 cycle) t (Duty pulse) w (1 cycle) Write m m m Write p p p Write r r Match detection r Match detection r r+1 s 01 r r+1 s 01 Counter clear t
Timer stop
w t+1 01 0
Counter clear Write t t
Counter clear
Match detection s Write w w
Match detection
Write s s Match detection s Match detection
Match detection
w
Returns to the level selected at TFF0
When the double buffer is enabled (T00MOD="1")
Figure 14-9 8-bit PPG Mode Timing Chart
T00MOD
Source clock Counter Write to T00PWM (T00REG) T00PWM (T00REG) PPG0 pin output n n-5 n-4 n-3 Write n-2 Match detection n-2 n-2 n-1 n
Figure 14-10 Operation When T00PWM (T00REG) and the Up Counter Have the Same Value
RA002 Page 187
14. 8-bit Timer Counter (TC0)
TMP89FM42
14.4.5 16-bit timer mode
In the 16-bit timer mode, TC00 and TC01 are cascaded to form a 16-bit timer counter, which can measure a longer period than an 8-bit timer.
14.4.5.1 Setting
Setting T001CR to "1" connects TC00 and TC01 and activates the 16-bit mode. All the settings of TC00 are ignored and those of TC01 are effective in the 16-bit mode. The 16-bit timer mode is activated by setting T01MOD to "00" or "01" and T01MOD to "0". Select the source clock at T01MOD. Set the count value to be used for the match detection as a 16-bit value at the timer registers T00REG and T01REG. Set the lower 8 bits of the 16-bit value at T00REG and the higher 8 bits at T01REG. (Hereinafter, the 16-bit value specified by the combined setting of T01REG and T00REG is indicated as T01+00REG.) The timer register settings are reflected on the double buffer or T01+00REG when a write instruction is executed on T01REG. Be sure to execute the write instructions on T00REG and T01REG in this order. (When data is written to the high-order register, the set values of the low-order and high-order registers become effective at the same time.) Set T01MOD to "1" to use the double buffer. Setting T001CR to "1" starts the operation. After the timer is started, writing to T01MOD becomes invalid. Be sure to complete the required mode settings before starting the timer. (Make settings when T001CR and are "0".)
14.4.5.2 Operations
Setting T001CR to "1" allows the 16-bit up counter to increment based on the selected internal source clock. When a match between the up counter value and the T00+01REG set value is detected, an INTT01 interrupt request is generated and the up counter is cleared to "0x0000". After being cleared, the up counter restarts counting. Setting T001CR to "0" during the timer operation makes the up counter stop counting and be cleared to "0x0000".
14.4.5.3 Double buffer
The double buffer can be used for T01+00REG by setting T01MOD. The double buffer is disabled by setting T01MOD to "0" or enabled by setting T01MOD to "1". * When the double buffer is enabled When write instructions are executed on T00REG and T01REG in this order during the timer operation, the set value is first stored in the double buffer, and T01+00REG is not updated immediately. T01+00REG compares the previous set value with the up counter value. When the values are matched, an INTT01 interrupt request is generated and the double buffer set value is stored in T01+00REG. Subsequently, the match detection is executed using a new set value. When write instructions are executed on T00REG and T01REG in this order while the timer is stopped, the set value is immediately stored in both the double buffer and T01+00REG. * When the double buffer is disabled When write instructions are executed on T00REG and T01REG in this order during the timer operation, the set value is immediately stored in T01+00REG. Subsequently, the match detection is executed using a new set value.
RA002
Page 188
TMP89FM42
If the value set to T01+00REG is smaller than the up counter value, the match detection is executed using a new set value after the up counter overflows. Therefore, the interrupt request interval may be longer than the selected time. If the value set to T01+00REG is equal to the up counter value, the match detection is executed immediately after data is written into T01+00REG. Therefore, the interrupt request interval may not be an integral multiple of the source clock. If these are problems, enable the double buffer. When write instructions are executed on T00REG and T01REG in this order while the timer is stopped, the set value is immediately stored in T01+00REG. When a read instruction is executed on T01+00REG, the last value written into T01+00REG is read out, regardless of the T00MOD setting.
(Example)
Operate TC00 and TC01 in the 16-bit timer mode with the operation clock of fcgck/2 [Hz] and generate interrupts at 96 s intervals (fcgck = 10 MHz)
LD DI SET EI LD LD LD LD
(POFFCR0),0x10 (EIRH).4 (T01MOD),0xF0 (T00REG),0xE0 (T01REG),0x01 (T001CR),0x06
; Sets TC001EN to "1" ; Sets the interrupt master enable flag to "disable" ; Sets the INTTC00 interrupt enable register to "1" ; Sets the interrupt master enable flag to "enable" ; Selects the 16-bit timer mode and fcgck/2 ; Sets the timer register (96s / (2/fcgck) = 0x1E0) ; Sets the timer register ; Starts TC00 and TC001 (16-bit mode)
RA002
Page 189
14. 8-bit Timer Counter (TC0)
TMP89FM42
Timer start T001CR T01MOD Source clock Counter Write to T00REG Write to T01REG T01+00REG INTT01 interrupt request km 0 sr 1 2 3 Write r Write s Match detection km Reflected by writing to T01REG Match detection sr sr-1 0 1 2
Timer stop
0 Write m Write k
1
2
3
4
km-1
0
Counter clear
Counter clear
Reflected by writing to T01REG When the double buffer is disabled (T01MOD="0") Timer start
T001CR T01MOD Source clock km Counter Write to T00REG Write to T01REG Double buffer T01+00REG INTT01 interrupt request 0 Write m Write k km Match detection km Reflected simultaneously by writing to T01REG while the timer is stopped 1 2 3 4 km-1 0 1 2 3 Write r Write s sr Match detection sr Match detection km-1 Counter clear km 0 1 sr-1 Counter clear sr 0 1
Reflected by an interrupt Reflected by writing to T01REG
When the double buffer is enabled (T01MOD="1")
Figure 14-11 16-bit Timer Counter Timing Chart
RA002
Page 190
TMP89FM42
Table 14-9 16-bit Timer Mode Resolution and Maximum Time Setting
Source clock [Hz] T01MOD NORMAL1/2 or IDLE1/2 mode SYSCR1 = "0" fcgck/211 fcgck/210 fcgck/28 fcgck/26 fcgck/24 fcgck/22 fcgck/2 fcgck SYSCR1 = "1" fs/24 fs/23 fcgck/28 fcgck/26 fcgck/24 fcgck/22 fcgck/2 fcgck SLOW1/2 or SLEEP1 mode fcgck=10MHz fs=32.768KHz fcgck=10MHz fs=32.768KHz Resolution Maximum time setting
000 001 010 011 100 101 110 111
fs/24 fs/23 fs/22
204.8s 102.4s 25.6s 6.4s 1.6s 400ns 200ns 100ns
488.2s 244.1s 122.1s
13.4s 6.7s 1.7s 419.4ms 104.9ms 26.2ms 13.1ms 6.6ms
32s 16s 8s
RA002
Page 191
14. 8-bit Timer Counter (TC0)
TMP89FM42
14.4.6 16-bit event counter mode
In the 16-bit event counter mode, the up counter counts up at the falling edge of the input to the TC00 pin. TC00 and TC01 are cascaded to form a 16-bit timer counter, which can measure a longer period than an 8-bit timer.
14.4.6.1 Setting
Setting T001CR to "1" connects TC00 and TC01 and activates the 16-bit timer mode. All the settings of TC00 are ignored and those of TC01 are effective in the 16-bit timer mode. The 16-bit timer mode is activated by setting T01MOD to "00" or "01" and T01MOD to "1". Set the count value to be used for the match detection as a 16-bit value at the timer registers T00REG and T01REG. Set the lower 8 bits of the 16-bit value at T00REG and set the higher 8 bits at T01REG. (Hereinafter, the 16-bit value specified by the combined setting of T01REG and T00REG is indicated as T01+00REG.) The timer register settings are reflected on the double buffer or T01+00REG when a write instruction is executed on T01REG. Be sure to execute the write instructions on T00REG and T01REG in this order. (When data is written to the high-order register, the set values of the low-order and high-order registers become effective at the same time.) Set T01MOD to "1" to use the double buffer. Setting T001CR to "1" starts the operation. After the timer is started, writing to T01MOD becomes invalid. Be sure to complete the required mode settings before starting the timer. (Make settings when T001CR and are "0".)
14.4.6.2 Operations
Setting T001CR to "1" allows the 16-bit up counter to increment at the falling edge of the TC00 pin. When a match between the up counter value and the T00+01REG set value is detected, an INTT01 interrupt request is generated and the up counter is cleared to "0x0000". After being cleared, the up counter restarts counting. Setting T001CR to "0" during the timer operation makes the up counter stop counting and be cleared to "0x0000". The maximum frequency to be supplied is fcgck/2 [Hz] (in NORMAL1/2 or IDLE1/2 mode) or fs/24 [Hz] (in SLOW1/2 or SLEEP1 mode), and a pulse width of two machine cycles or more is required at both the "H" and "L" levels.
14.4.6.3 Double buffer
Refer to 14.4.5.3.
(Example) Operate TC00 and TC01 in the 16-bit event counter mode and generate an interrupt each time the 384th falling edge is detected at the TC00 pin
LD DI SET EI LD LD LD LD
(POFFCR0),0x10 (EIRH).4 (T00MOD),0xC4 (T00REG),0x80 (T01REG),0x10 (T001CR),0x06
; Sets TC001EN to "1" ; Sets the interrupt master enable flag to "disable" ; Sets the INTTC00 interrupt enable register to "1" ; Sets the interrupt master enable flag to "enable" ; Selects the 16-bit event counter mode ; Sets the timer register ; Sets the timer register ; Starts TC00 and TC001 (16-bit mode)
RA002
Page 192
TMP89FM42
Timer start T001CR TC00 pin input km Counter Write to T00REG Write to T01REG T01+00REG INTT00 interrupt request 0 Write m Write k Match detection km Reflected by writing to T01REG 1 2 3 4 km-1 0 1 2 3 Write s Write r Match detection rs rs-1 Counter clear rs 0 1 2
Timer stop
0 Counter clear
Counter clear
Reflected by writing to T01REG When the double buffer is disabled (T01MOD="0") Timer start
T001CR TC00 pin input km Counter Write to T00REG Write to T01REG Double buffer T01+00REG INTT00 interrupt request 0 Write m Write k km Match detection km Reflected by writing to T01REG 1 2 3 4 km-1 0 1 2 3 Write s Write r rs km-1 Counter clear km 0 1 rs-1 Counter clear rs 0 1 Counter clear
Match detection
rs
Match detection
Reflected by an interrupt
Reflected by writing to T01REG When the double buffer is enabled (T01MOD="1")
Figure 14-12 16-bit Event Counter Mode Timing Chart
RA002
Page 193
14. 8-bit Timer Counter (TC0)
TMP89FM42
14.4.7 12-bit pulse width modulation (PWM) output mode
In the 12-bit PWM output mode, TC00 and TC01 are cascaded to output the pulse-width modulated pulses with a resolution of 8 bits. An additional pulse of 4 bits can be inserted, which enables PWM output with a resolution nearly equivalent to 12 bits.
14.4.7.1 Setting
Setting T001CR to "1" connects TC00 and TC01 and activates the 16-bit timer mode. All the settings of TC00 are ignored and those of TC01 are effective in the 16-bit timer mode. The 12-bit PWM mode is selected by setting T01MOD to "10". To use the internal clock as the source clock, set T01MOD to "0" and select the clock at T01MOD. To use an external clock as the source clock, set T01MOD to "1". Set T01MOD to "1" to use the double buffer. Setting T001CR to "1" starts the operation. After the timer is started, writing to T01MOD becomes invalid. Be sure to complete the required mode settings before starting the timer. (Make settings when T001CR and are "0".) Set the count value to be used for the match detection and the additional pulse value as a 12-bit value at the timer registers T00PWM and T01PWM. Set bits 11 to 8 of the 12-bit value at the lower 4 bits of T01PWM and set bits 7 to 0 at T00PWM. Refer to the following table for the register configuration. Hereinafter, the 12-bit value specified by the combined setting of T00PWM and T01PWM is indicated as T01+00PWM. The timer register settings are reflected on the double buffer or T01+00PWM when a write instruction is executed on T01PWM. Be sure to execute the write instructions on T00PWM and T01PWM in this order. (When data is written to the high-order register, the set values of the low-order and highorder registers become effective at the same time.) Timer register 00
T00PWM (0x0028) Bit Symbol Read/Write After reset R/W 1 7 6 PWMDUTYL R/W 1 R/W 1 R/W 1 5 4 3 PWMAD3 R/W 1 2 PWMAD2 R/W 1 1 PWMAD1 R/W 1 0 PWMAD0 R/W 1
Timer register 01
T01PWM (0x0029) Bit Symbol Read/Write After reset 1 1 1 1 R/W 1 7 6 5 4 3 2 PWMDUTYH R/W 1 R/W 1 R/W 1 1 0
Bits 7 to 4 of T01PWM are not used in the 12-bit PWM mode. However, data can be written to these bits of T01PWM and the written values are read out as they are when the bits are read. Normally, set these bits to "0". PWMDUTYH and PWMDUTYL are 4-bit registers. They are combined to set an 8-bit value of duty pulse width (time before the first change in the output) for one cycle (256 counts of the source clock). Hereinafter, an 8-bit value specified by the combined setting of PWMDUTYH and PWMDUTYL is indicated as PWMDUTY. PWMAD3 to 0 are the additional pulse setting register. Additional pulses can be inserted in specific cycles of the duty pulse by setting each bit to "1". The additional pulses are inserted in the positions listed in Table 14-10. PWMAD 3 to 0 can be combined to specify the number of times of inserting the additional pulses in 16 cycles to any number from 1 to 16. Examples of inserting additional pulses are shown in Figure 14-13.
RA002
Page 194
TMP89FM42
Table 14-10 Cycles in Which Additional Pulses Are Inserted
Cycles in which additional pulses are inserted among cycles 1 to 16 PWMAD0="1" PWMAD1="1" PWMAD2="1" PWMAD3="1" 9 5, 13 3, 7, 11, 15 2, 4, 6, 8, 10, 12, 14, 16
Set the initial state of the PWM1 pin at T01MOD. Setting T01MOD to "0" selects the "L" level as the initial state of the PWM1 pin. Setting T01MOD to "1" selects the "H" level as the initial state of the PWM1 pin. If the PWM1 pin is set as the function output pin in the port setting while the timer is stopped, the value of T01MOD is output to the PWM1 pin. Table 14-11 shows the list of output levels of the PWM1 pin. Table 14-11 List of Output Levels of PWM1 Pin
PWM1pin output level
TFF1
Before the start of operation (initial state) L H
PWMDUTY matched (after the additional pulse) H L
Overflow
Operation stopped (initial state) L H
0 1
L H
RA002
Page 195
14. 8-bit Timer Counter (TC0)
TMP89FM42
Timer start
Additional pulse
Additional pulse
Timer stop
PWM1 pin output (TFF1="1")
PWM1 pin output (TFF1="0") INTT00 interrupt request INTT01 interrupt request
Cycle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
When PWMAD1="1"
Timer start PWM1 pin output (TFF1="1")
Additional pulse
Additional pulse
Additional pulse
Additional pulse
Additional pulse
Timer stop
PWM1 pin output (TFF1="0") INTT00 interrupt request INTT01 interrupt request
Cycle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
When PWMAD0 = "1" and PWMAD2 = "1"
Figure 14-13 Examples of Inserting Additional Pulses
14.4.7.2 Operations
Setting T001CR to "1" allows the up counter to increment based on the selected source clock. When a match between the lower 8 bits of the up counter value and the value set to PWMDUTY is detected, the output of the PWM1 pin is reversed. When T01MOD is "0", the PWM1 pin changes from the "L" to "H" level. When T01MOD is "1", the PWM1 pin changes from the "H" to "L" level. If any of PWMAD3 to 0 is "1", an additional pulse that corresponds to 1 count of the source clock is inserted in specific cycles of the duty pulse. In other words, the PWM1 pin output is reversed at the timing of PWMDUTY+1. When T00MOD is "0", the period of the "L" level becomes longer than the value set to PWMDUTY by 1 source clock. When T00MOD is "1", the period of the "H" level becomes longer than the value set to PWMDUTY by 1 source clock. This function allows 16 cycles of output pulses to be handled with a resolution nearly equivalent to 12 bits. No additional pulse is inserted when PWMAD3 to 0 are all "0". Subsequently, the up counter continues counting up. When the up counter value reaches 256, an overflow occurs and the up counter is cleared to "0x00". At the same time, the output of the PWM1 pin is reversed. When T01MOD is "0", the PWM1 pin changes from the "H" to "L" level. When T01MOD is "1", the PWM1 pin changes from the "L" to "H" level. At this time, an INTT00 inter-
RA002
Page 196
TMP89FM42
rupt request is generated (an INTT00 interrupt request is generated each time an overflow occurs.) An INTT01 interrupt request is generated at the 16 x n-th overflow (n=1, 2, 3...). Subsequently, the up counter continues counting up. When T001CR is set to "0" during the timer operation, the up counter is stopped and cleared to "0x00". The PWM1 pin returns to the level selected at T01MOD. When an external source clock is selected, input the clock at the TC00 pin. The maximum frequency to be supplied is fcgck/2 [Hz] (in NORMAL1/2 or IDLE1/2 mode) or fs/24 [Hz] (in SLOW1/2 or SLEEP1 mode), and a pulse width of two machine cycles or more is required at both the "H" and "L" levels.
Additional pulse (1 source clock) (Duty pulse width) PWMDUTY
Timer start
(Duty pulse width) PWMDUTY PWM1 pin output (TFF0="1")
PWM1 pin output (TFF0="0") 256 counts (cycle width) 256 counts (cycle width)
Figure 14-14 PWM1 Pin Output
14.4.7.3 Double buffer
The double buffer can be used for T01+00PWM by setting T01MOD. The double buffer is disabled by setting T01MOD to "0" or enabled by setting T01MOD to "1". * When the double buffer is enabled When write instructions are executed on T00PWM and T01PWM in this order during the timer operation, the set value is first stored in the double buffer, and T01+00PWM is not updated immediately. T01+00PWM compares the previous set value with the up counter value. When the 16 x n-th overflow occurs, an INTT01 interrupt request is generated and the double buffer set value is stored in T01+00PWM. Subsequently, the match detection is executed using a new set value. When a read instruction is executed on T01+00PWM (T00REG), the value in the double buffer (the last set value) is read out, not the T01+00PWM value (the currently effective value). When write instructions are executed on T00PWM and T01PWM in this order while the timer is stopped, the set value is immediately stored in both the double buffer and T01+00PWM. * When the double buffer is disabled When write instructions are executed on T00PWM and T01PWM in this order during the timer operation, the set value is immediately stored in T01+00PWM. Subsequently, the match detection is executed using a new set value. If the value set to T01+00PWM is smaller than the up counter value, the PWM1 pin is not reversed until the up counter overflows and a match detection is executed using a new set value. If the value set to T01+00PWM is equal to the up counter value, the match detection is executed immediately after data is written into T01+00PWM. Therefore, the timing of changing the PWM1 pin may not be an integral multiple of the source clock. Similarly, if T01+00PWM is set during the additional pulse output, the timing of changing the PWM1 pin may not be an integral multiple of the source clock. If these are problems, enable the double buffer.
RA002
Page 197
14. 8-bit Timer Counter (TC0)
TMP89FM42
When write instructions are executed on T00PWM and T01PWM in this order while the timer is stopped, the set value is immediately stored in T01+00PWM.
(Example)
Operate TC00 and TC01 in the 12-bit PWM mode with the operation clock of fcgck/2 and output a duty pulse nearly equivalent to 14.0625 s in 51.2s cycles (fcgck = 10 MHz) (Actually, output a duty pulse of 225 s in total in 16 cycles (819.2 s))
SET SET LD DI SET EI LD LD LD LD
(P7FC).1 (P7CR).1 (POFFCR0),0x10 (EIRH).4 (T01MOD),0xF2 (T00PWM),0x65 (T00PWM),0x04 (T001CR),0x06
; Sets P7FC1 to "1" ; Sets P7CR1 to "1" ; Sets TC001EN to "1" ; Sets the interrupt master enable flag to "disable" ; Sets the INTTC00 interrupt enable register to "1" ; Sets the interrupt master enable flag to "enable" ; Selects the 16-bit PWM mode and fcgck/2 ; Sets the timer register (duty pulse) ; (14.0625s x 16) / (2/fcgck) = 0x465 ; Sets the timer register (duty pulse) ; Starts TC00 and TC01
Timer start T001CR T00MOD Source clock Overflow 256 01 Counter clear Write to T00PWM Write to T01PWM Double buffer PWMAD3 ~ 0 PWMDUTY PWM0 pin output INTT00 interrupt request INTT00 interrupt request km (Duty pulse) 256 counts (Cycle 1) km (Duty pulse) 256 counts (Cycle 2) km+1 (Duty pulse) 256 counts (Cycle 9) km (Duty pulse) 256 counts (Cycle 16) rs (Duty pulse) (Cycle 17) Becomes the level selected at TFF0 while the timer is stopped Additional pulse Interrupt request Interrupt request Interrupt request Interrupt reques Write m (0001) Write k km (0001) 0001 km Match detection Match detection Match detection Overflow 256 01 Counter clear Overflow 256 01 256 01 Counter clear
Counter
0
1
km km +1
km km +1
km km +1
km km +1
rs
Counter clear Write s (0011) Write r rs (0011)
0011 Match detection rs
When the double buffer is enabled (T01MOD="1")
Figure 14-15 12-bit PWM Mode Timing Chart
RA002
Page 198
TMP89FM42
Table 14-12 Resolutions and Cycles in the 12-bit PWM Mode
Source clock [Hz] T01MOD NORMAL1/2 or IDLE1/2 mode SYSCR1 = "0" 000 fcgck/211 SYSCR1 = "1" fs/24 SLOW1/2 or SLEEP1 mode fcgck=10MHz fs=32.768KHz fcgck=10MHz fs=32.768KHz Resolution 8-bit cycle (period x 16)
fs/24
204.8s
488.2s
52.4ms (838.9ms) 26.2ms (419.4ms) 6.6ms (104.9ms) 1.6ms (26.2ms) 409.6s (6.6ms) 102.4s (1.6ms) 51.2s (819.2s) 25.6s (409.6s)
125ms (2000ms) 62.5ms (1000ms) -
001
fcgck/210
fs/23
fs/23
102.4s
244.1s
010
fcgck/28
fcgck/28
-
25.6s
-
011
fcgck/26
fcgck/26
-
6.4s
-
-
100
fcgck/24
fcgck/24
-
1.6s
-
-
101
fcgck/22
fcgck/22
-
400ns
-
-
110
fcgck/2
fcgck/2
-
200ns
-
31.3ms (500ms)
111
fcgck
fcgck
fs/22
100ns
122.1s
RA002
Page 199
14. 8-bit Timer Counter (TC0)
TMP89FM42
14.4.8 16-bit programmable pulse generate (PPG) output mode
In the 16-bit PPG mode, TC00 and TC01 are cascaded to output the pulses that have a resolution of 16 bits and arbitrary pulse width and duty. Two 16-bit registers, T01+00REG and T01+00PWM, are used to output the pulses. This enables output of longer pulses than an 8-bit timer.
14.4.8.1 Setting
Setting T001CR to "1" connects TC00 and TC01 and activates the 16-bit mode. All the settings of TC00 are ignored and those of TC01 are effective in the 16-bit mode. The 16-bit PPG mode is selected by setting T01MOD to "11". To use the internal clock as the source clock, set T01MOD to "0" and select the clock at T01MOD. To use an external clock as the source clock, set T01MOD to "1". Set T01MOD to "1" to use the double buffer. Set the count value that corresponds to a cycle as a 16-bit value at the timer registers T01REG and T00REG. Set the count value that corresponds to a duty pulse as a 16-bit value at T01PWM and T00PWM (hereinafter, the 16-bit value specified by the combined setting of T01REG and T00REG is indicated as T01+00REG, and the 16-bit value specified by the combined setting of T01PWM and T00PWM is indicated as T01+00PWM). The timer register settings are reflected on the double buffer or T01+00PWM and T01+00REG when a write instruction is executed on T01PWM. Be sure to execute the write instructions on T00REG, T01REG and T00PWM before executing a write instruction on T01PWM. (When data is written to T01PWM, the set values of the four timer registers become effective at the same time.) Set the initial state of the PPG1 pin at T01MOD. Setting T01MOD to "0" selects the "L" level as the initial state of the PPG1 pin. Setting T01MOD to "1" selects the "H" level as the initial state of the PPG1 pin. If the PPG1 pin is set as the function output pin in the port setting while the timer is stopped, the value of T01MOD is output to the PPG1 pin. Table 14-13 shows the list of output levels of the PPG1 pin. Table 14-13 List of Output Levels of PPG1 Pin
PPG1 pin output level
TFF1
Before the start of operation (initial state) L H
T01+00PWM matched H L
T01+00REG matched L H
Operation stopped (initial state) L H
0 1
14.4.8.2 Operations
Setting T001CR to "1" allows the up counter to increment based on the selected source clock. When a match between the up counter value and the value set to T01+00PWM is detected, the output of the PPG1 pin is reversed. When T01MOD is "0", the PPG1 pin changes from the "L" to "H" level. When T01MOD is "1", the PPG1 pin changes from the "H" to "L" level. At this time, an INTT00 interrupt request is generated. The up counter continues counting up. When a match between the up counter value and the value set to T01+00REG is detected, the output of the PPG1 pin is reversed again. When T01MOD is "0", the PPG1 pin changes from the "H" to "L" level. When T01MOD is "1", the PPG1 pin changes from the "L" to "H" level. At this time, an INTT01 interrupt request is generated and the up counter is cleared to "0x0000". When T001CR is set to "0" during the timer operation, the up counter is stopped and cleared to "0x0000". The PPG1 pin returns to the level selected at T01MOD.
RA002
Page 200
TMP89FM42
When an external source clock is selected, input the clock at the TC00 pin. The maximum frequency to be supplied is fcgck/2 [Hz] (in NORMAL1/2 or IDLE1/2 mode) or fs/24 [Hz] (in SLOW1/2 or SLEEP1 mode), and a pulse width of two machine cycles or more is required at both the "H" and "L" levels.
14.4.8.3 Double buffer
The double buffer can be used for T01+00PWM and T01+00REG by setting T01MOD. The double buffer is enabled by setting T01MOD to "0" or disabled by setting T01MOD to "1". * When the double buffer is enabled When a write instruction is executed on T01PWM after write instructions are executed on T00REG, T01REG and T00PWM during the timer operation, the set values are first stored in the double buffer, and T01+00PWM and T01+00REG are not updated immediately. T01+00PWM and T01+00REG compare the previous set values with the up counter value. When a match between the up counter value and the T01+00REG set value is detected, an INTT01 interrupt request is generated and the double buffer set values are stored in T01+00PWM and T01+00REG. Subsequently, the match detection is executed using new set values. When a write instruction is executed on T01PWM after write instructions are executed on T00REG, T01REG and T00PWM while the timer is stopped, the set values are immediately stored in both the double buffer and T01+00PWM and T01+00REG. * When the double buffer is disabled When a write instruction is executed on T01PWM after write instructions are executed on T00REG, T01REG and T00PWM during the timer operation, the set values are immediately stored in T01+00PWM and T01+00REG. Subsequently, the match detection is executed using new set values. If the value set to T01+00PWM or T01+00REG is smaller than the up counter value, the
PPG1 pin is not reversed until the up counter overflows and a match detection is executed using
a new set value. If the value set to T01+00PWM or T01+00REG is equal to the up counter value, the match detection is executed immediately after data is written into T01+00PWM and T01+00REG. Therefore, the timing of changing the PPG1 pin may not be an integral multiple of the source clock. If these are problems, enable the double buffer. When a write instruction is executed on T01PWM after write instructions are executed on T00REG, T01REG and T00PWM while the timer is stopped, the set values are immediately stored in T01+00PWM and T01+00REG. When read instructions are executed on T01+00PWM and T01+00REG, the last value written into T01+00REG is read out, regardless of the T00MOD setting.
(Example)
Operate TC00 and TC01 in the 16-bit PPG mode with the operation clock of fcgck/2 and output the 68s duty pulse in 96s cycles (fcgck = 10 MHz)
SET SET LD DI SET EI LD LD LD LD LD
(P7FC).1 (P7CR).1 (POFFCR0),0x10 (EIRH).4 (T01MOD),0xF3 (T00REG),0xE0 (T01REG),0x01 (T00PWM),0x54 (T01PWM),0x01
; Sets P7FC0 to "1" ; Sets P7CR0 to "1" ; Sets TC001EN to "1" ; Sets the interrupt master enable flag to "disable" ; Sets the INTTC00 interrupt enable register to "1" ; Sets the interrupt master enable flag to "enable" ; Selects the 8-bit PPG mode and fcgck/2 ; Sets the timer register (cycle) ; Sets the timer register (cycle) ; 96s / (2/fcgck) = 0x01E0 ; Sets the timer register (duty pulse) ; Sets the timer register (duty pulse) ; 68s / (2/fcgck) = 0x0154
RA002
Page 201
14. 8-bit Timer Counter (TC0)
TMP89FM42
LD
(T001CR),0x06
; Starts TC00 and TC01
Timer start T001CR T01MOD Source clock ab Counter 0 1 gh gh +1 01 Counter clear Write to T00REG Write to T01REG Double buffer T01+00REG Write to T00PWM Write to T01PWM Double buffer T01+00PWM PPG1 pin output INTT00 interrupt request INTT00 interrupt request Becomes the level selected at TFF1 while the timer is stopped gh (Duty pulse) ab (Cycle 1) km (Duty pulse) cd (Cycle 1) km (Duty pulse) cd (Cycle 1) qr (Duty pulse) ef (Cycle 1) Write b Write a ab ab Write h Write g gh gh Match detection Write d Write c cd cd Match detection km km +1 cd 01 km km +1 cd 01 Counter clear
Timer stop
ef qr qr +1 01 0
Counter clear Write f Write e ef Match detection Write r Write q qr Match detection
Counter clear
ef
Match detection
Write m Write k km Match detection km
Match detection qr
Match detection
Returns to the level selected at TFF1
When the double buffer is enabled (T01MOD="1")
Figure 14-16 16-bit PPG Output Mode Timing Chart
RA002
Page 202
TMP89FM42
15. Real Time Clock (RTC)
The real time clock is a function that generates interrupt requests at certain intervals using the low-frequency clock. The number of interrupts is counted by the software to realize the clock function. The real time clock can be used only in the operation modes where the low-frequency clock oscillates, except for SLEEP0.
15.1 Configuration
RTCCR
RTCSEL RTCRUN fs (32.768 kHz)
15 14 13
Selector
2 /fs 2 /fs 2 /fs 2 /fs 2 /fs
12 11
INTRTC interrupt request
2 /fs 2 /fs
10 9
2 /fs
8
Binary counter
Figure 15-1 Real Time Clock
15.2 Control
The real time clock is controlled by following resisters. Low power consumption register 2
POFFCR2 (0x0F76) Bit Symbol Read/Write After reset 7 R/W 0 6 R/W 0 5 RTCEN R/W 0 4 R/W 0 3 R/W 0 2 R/W 0 1 R/W 0 0 SIO0EN R/W 0
RTCEN
RTC control
0 1 0 1
Disable Enable Disable Enable
SIO0EN
SIO0 control
Real time clock control register
RTCCR (0x0FC8) 7 Bit Symbol Read/Write After reset R 0 6 R 0 5 R 0 4 R 0 0 3 2 RTCSEL R/W 0 0 1 0 RTCRUN R/W 0
RA000
Page 203
15. Real Time Clock (RTC)
15.3 Function TMP89FM42
000 : 215/fs (1.000 [s] @fs=32.768kHz) 001 : 214/fs (0.500 [s] @fs=32.768kHz) 010 : 213/fs (0.250 [s] @fs=32.768kHz) RTCSEL Selects the interrupt generation interval 011 : 212/fs (125.0 [ms] @fs=32.768kHz) 100 : 211/fs (62.50 [ms] @fs=32.768kHz) 101 : 210/fs (31.25 [ms] @fs=32.768kHz) 110 : 29/fs (15.62 [ms] @fs=32.768kHz) 111 : 28/fs (7.81 [ms] @fs=32.768kHz) RTCRUN Enables/disables the real time clock operation 0 : Disable 1 : Enable
Note 1: fs: Low-frequency clock [Hz] Note 2: RTCCR can be rewritten only when RTCCR is "0". If data is written into RTCCR when RTCCR is "1", the existing data remains effective. RTCCR can be rewritten at the same time as enabling the real time clock, but it cannot be rewritten at the same time as disabling the real time clock. Note 3: If the real time clock is enabled and when 1) SYSCR2 is cleared to "0" to stop the low-frequency clock oscillation circuit or 2) the operation is changed to the STOP mode or the SLEEP0 mode, the data in RTCCR is maintained and RTCCR is cleared to "0".
15.3 Function
15.3.1 Low Power Consumption Function
Real time clock has the low power consumption registers (POFFCR2) that save power when the real time clock is not being used. Setting POFFCR2 to "0" disables the basic clock supply to real time clock to save power. Note that this renders the real time clock unusable. Setting POFFCR2 to "1" enables the basic clock supply to real time clock and allows the real time clock to operate. After reset, POFFCR2 are initialized to "0", and this renders the real time clock unusable. When using the real time clock for the first time, be sure to set POFFCR2 to "1" in the initial setting of the program (before the real time clock control registers are operated). Do not change POFFCR2 to "0" during the real time clock operation. Otherwise real time clock may operate unexpectedly.
15.3.2 Enabling/disabling the real time clock operation
Setting RTCCR to "1" enables the real time clock operation. Setting RTCCR to "0" disables the real time clock operation. RTCCR is cleared to "0" just after reset release.
15.3.3 Selecting the interrupt generation interval
The interrupt generation interval can be selected at RTCCR. RTCCR can be rewritten only when RTCCR is "0". If data is written into RTCCR when RTCCR is "1", the existing data remains effective. RTCCR can be rewritten at the same time as enabling the real time clock operation, but it cannot be rewritten at the same time as disabling the real time clock operation.
RA000
Page 204
TMP89FM42
15.4 Real Time Clock Operation
15.4.1 Enabling the real time clock operation
Set the interrupt generation interval to RTCCR, and at the same time, set RTCCR to "1". When RTCCR is set to "1", the binary counter for the real time clock starts counting of the lowfrequency clock. When the interrupt generation interval selected at RTCCR is reached, a real time clock interrupt request (INTRTC) is generated and the counter continues counting.
15.4.2 Disabling the real time clock operation
Clear RTCCR to "0". When RTCCR is cleared to "0", the binary counter for the real time clock is cleared to "0" and stops counting of the low-frequency clock.
RA000
Page 205
15. Real Time Clock (RTC)
15.4 Real Time Clock Operation TMP89FM42
RA000
Page 206
TMP89FM42
16. Asynchronous Serial Interface (UART)
The TMP89FM42 contains 2 channels of asynchronous serial interfaces (UART). This chapter describes asynchronous serial interface 0 (UART0). For UART1, replace the SFR addresses and pin names as shown in Table 16-1 and Table 16-2. Table 16-1 SFR Address Assignment
UARTxCR1 (address) UART0 UART0CR1 (0x001A) UART1CR1 (0x0F54) UARTxCR2 (address) UART0CR2 (0x001B) UART1CR2 (0x0F55) UARTxDR (address) UART0DR (0x001C) UART1DR (0x0F56) UARTxSR (address) UART0SR (0x001D) UART1SR (0x0F57) RDxBUF (address) RD0BUF (0x001E) RD1BUF (0x0F58) TDxBUF (address) TD0BUF (0x001E) TD1BUF (0x0F58)
UART1
Table 16-2 Pin Names
Serial data input pin UART0 UART1 RXD0 pin RXD1 pin Serial data output pin TXD0 pin TXD1 pin
RA001
Page 207
16. Asynchronous Serial Interface (UART)
16.1 Configuration TMP89FM42
16.1 Configuration
UART0 control register 1 UART0CR1
UART0 transmit data buffer UART0CR1 UART0 receive data buffer RD0BUF
2
2 Transmit control circuit
Shift register
Receive control circuit
Shift register
Parity bit Stop bit
Noise rejection circuit RXD0
INTTXD0 interrupt request
INTRXD0 interrupt request Baud rate generator
IrDA control
TXD0
S S A B Y
Transmit RT clock Transmission start EN
Y
Receive RT clock
Y A B C S 2
PPGA0 output (TCA0 output)
A B Counter
fcgck/26 7 Frequency fcgck/2 divider fcgck/28
Selector
Counter
24
UART0SR UART0 status register UART0CR2 UART0 control register 2
fcgck or fs 8-bit counter
EN Start bit detection Comparator
8-bit counter
Comparator
Match detection
Match detection
UART0DR UART0 baud rate register
Figure 16-1 Asynchronous Serial Interface (UART)
RA001
Page 208
TMP89FM42
16.2 Control
UART0 is controlled by the low power consumption registers (POFFCR1), UART0 control registers 1 and 2 (UART0CR1 and UART0CR2) and the UART0 baud rate register (UART0DR). The operating status can be monitored using the UART status register (UART0SR). Low power consumption register 1
POFFCR1 (0x0F75) Bit Symbol Read/Write After reset 7 R/W 0 6 R/W 0 5 R/W 0 4 SBI0EN R/W 0 3 R/W 0 2 R/W 0 1 UART1EN R/W 0 0 UART0EN R/W 0
SBI0EN
I2C0 control
0 1 0 1 0 1
Disable Enable Disable Enable Disable Enable
UART1EN
UART1 control
UART0EN
UART0 control
RA001
Page 209
16. Asynchronous Serial Interface (UART)
16.2 Control TMP89FM42
UART0 control register 1
UART0CR1 (0x001A) Bit Symbol Read/Write After reset 7 TXE R/W 0 6 RXE R/W 0 5 STOPBT R/W 0 4 EVEN R/W 0 3 PE R/W 0 2 IRDASEL R/W 0 1 BRG R/W 0 0 R 0
TXE
Transmit operation
0: 1: 0: 1: 0: 1: 0: 1: 0: 1: 0: 1:
Disable Enable Disable Enable 1 bit 2 bits Odd-numbered parity Even-numbered parity No parity Parity added UART output IrDA output When SYSCR2 is "0" When SYSCR2 is "1" fs TCA0 output
RXE
Receive operation
STOPBT
Transmit stop bit length
EVEN
Parity selection
PE
Parity addition
IRDASEL
TXD pin output selection
BRG
Transfer base clock selection
0: 1:
fcgck
Note 1: fcgck, Gear clock; fs, Low-frequency clock Note 2: If the TXE or RXE bit is set to "0" during the transmission or receiving of data, the operation is not disabled until the data transfer is completed. At this time, the data stored in the transmit data buffer is discarded. Note 3: EVEN, PE and BRG settings are common to transmission and receiving. Note 4: Set RXE and TXE to "0" before changing BRG. Note 5: When BRG is set to the TCA0 output, the RT clock becomes asynchronous and the start bit of the transmitted/received data may get shorter by a maximum of (UART0DR+1)/(Transfer base clock frequency)[s]. If the pin is not used for the TCA0 output, control the TCA0 output by using the port function control register. Note 6: To prevent STOPBT, EVEN, PE, IRDASEL and BRG from being changed accidentally during the UART communication, the register cannot be rewritten during the UART operation. For details, refer to "16.4 Protection to Prevent UART0CR1 and UART0CR2 Registers from Being Changed". Note 7: When the STOP, IDLE0 or SLEEP0 mode is activated, TXE and RXE are cleared to "0" and the UART stops. Other bits keep their values.
RA001
Page 210
TMP89FM42
UART0 control register 2
UART0CR2 (0x001B) Bit Symbol Read/Write After reset 7 R 0 6 R 0 0 5 4 RTSEL R/W 0 0 0 3 2 RXDNC R/W 0 1 0 STOPBR R/W 0
Odd-numbered bits of transfer frame 000: 001: RTSEL Selects the number of RT clocks 010: 011: 100: 101: 11*: Selects the RXD input noise rejection time (Time of pulses to be removed as noise) Receive stop bit length 00: 01: 10: 11: 0: 1: 16 clocks 16 clocks 15 clocks 15 clocks 17 clocks Reserved Reserved
Even-numbered bits of transfer frame 16 clocks 17 clocks 15 clocks 16 clocks 17 clocks
RXDNC
No noise rejection 1 x (UART0DR+1)/(Transfer base clock frequency) [s] 2 x (UART0DR+1)/(Transfer base clock frequency) [s] 4 x (UART0DR+1)/(Transfer base clock frequency) [s] 1 bit 2 bits
STOPBR
Note 1: When a read instruction is executed on UART0CR2, bits 7 and 6 are read as "0". Note 2: RTSEL can be set to two kinds of RT clocks for the even- and odd-numbered bits of the transfer frame. For details, refer to "16.8.1 Transfer baud rate calculation method". Note 3: For details of the RXDNC noise rejection time, refer to "16.10 Received Data Noise Rejection". Note 4: When the STOP, IDLE0 or SLEEP0 mode is activated, the UART stops automatically but each bit value of UART0CR2 remains unchanged. Note 5: When STOPBR is set to 2 bits, the first bit of the stop bits (during data receiving) is not checked for a framing error. Note 6: To prevent RTSEL, RXDNC and STOPBR from being changed accidentally during the UART communication, the register cannot be rewritten during the UART operation. For details, refer to "16.4 Protection to Prevent UART0CR1 and UART0CR2 Registers from Being Changed".
UART0 baud rate register
UART0DR (0x001C) Bit Symbol Read/Write After reset 7 UART0DR7 R/W 0 6 UART0DR6 R/W 0 5 UART0DR5 R/W 0 4 UART0DR4 R/W 0 3 UART0DR3 R/W 0 2 UART0DR2 R/W 0 1 UART0DR1 R/W 0 0 UART0DR0 R/W 0
Note 1: Set UART0CR1 and UART0CR1 to "0" before changing UART0DR. For the set values, refer to "16.8 Transfer Baud Rate". Note 2: When UART0CR1 is set to the TCA0 output, the value set to UART0DR has no meaning. Note 3: When the STOP, IDLE0 or SLEEP0 mode is activated, the UART stops automatically but each bit value of UART0DR remains unchanged.
UART0 status register
UART0SR (0x001D) Bit Symbol Read/Write After reset 7 PERR R 0 6 FERR R 0 5 OERR R 0 4 R 0 3 RBSY R 0 2 RBFL R 0 1 TBSY R 0 0 TBFL R 0
RA001
Page 211
16. Asynchronous Serial Interface (UART)
16.2 Control TMP89FM42
PERR
Parity error flag
0: 1: 0: 1: 0: 1: 0: 1: 0: 1: 0: 1: 0: 1:
No parity error Parity error No framing error Framing error No overrrun error Overrun error Before receiving or end of receiving On receiving Receive buffer empty Receive buffer full Before transmission or end of transmission On transmitting Transmit buffer empty Transmit buffer full (Transmit data writing is completed)
FERR
Framing error flag
OERR
Overrun error flag
RBSY
Receive busy flag
RBFL
Receive buffer full flag
TBSY
Transmit busy flag
TBFL
Transmit buffer full flag
Note 1: TBFL is cleared to "0" automatically after an INTTXD0 interrupt request is generated, and is set to "1" when data is set to TD0BUF. Note 2: When a read instruction is executed on UART0SR, bit 4 is read as "0". Note 3: When the STOP, IDLE0 or SLEEP0 mode is activated, each bit of UART0SR is cleared to "0" and the UART stops.
UART0 receive data buffer
RD0BUF (0x001E) Bit Symbol Read/Write After reset 7 RD0DR7 R 0 6 RD0DR6 R 0 5 RD0DR5 R 0 4 RD0DR4 R 0 3 RD0DR3 R 0 2 RD0DR2 R 0 1 RD0DR1 R 0 0 RD0DR0 R 0
Note 1: When the STOP, IDLE0 or SLEEP0 mode is activated, the RD0BUF values become undefined. If received data is required, read it before activating the mode.
UART0 transmit data buffer
TD0BUF (0x001E) Bit Symbol Read/Write After reset 7 TD0DR7 W 0 6 TD0DR6 W 0 5 TD0DR5 W 0 4 TD0DR4 W 0 3 TD0DR3 W 0 2 TD0DR2 W 0 1 TD0DR1 W 0 0 TD0DR0 W 0
Note 1: When the STOP, IDLE0 or SLEEP0 mode is activated, the TD0BUF values become undefined.
RA001
Page 212
TMP89FM42
16.3 Low Power Consumption Function
UART0 has a low power consumption register (POFFCR1) that saves power consumption when the UART function is not used. Setting POFFCR1 to "0" disables the basic clock supply to UART0 to save power. Note that this renders the UART unusable. Setting POFFCR1 to "1" enables the basic clock supply to UART0 and renders the UART usable. After reset, POFFCR1 is initialized to "0", and this renders the UART unusable. When using the UART for the first time, be sure to set POFFCR1 to "1" in the initial setting of the program (before the UART control register is operated). Do not change POFFCR1 to "0" during the UART operation, otherwise UART0 may operate unexpectedly.
RA001
Page 213
16. Asynchronous Serial Interface (UART)
16.4 Protection to Prevent UART0CR1 and UART0CR2 Registers from Being Changed TMP89FM42
16.4 Protection to Prevent UART0CR1 and UART0CR2 Registers from Being Changed
The TMP89FM42 has a function that protects the registers from being changed so that the UART communication settings (for example, stop bit and parity) are not changed accidentally during the UART operation. Specific bits of UART0CR1 and UART0CR2 can be changed only under the conditions shown in Table 16-3. If a write instruction is executed on the register when it is protected from being changed, the bits remain unchanged and keep their previous values. Table 16-3 Changing of UART0CR1 and UART0CR2
Conditions that allow the bit to be changed Bit to be changed Function UART0CR1 UART0SR UART0CR1 UART0SR -
UART0CR1 UART0CR1 UART0CR1 UART0CR1 UART0CR1
Transmit stop bit length Parity selection
Both of these bits are "0"
All of these bits are "0" Parity addition TXD pin output selection Transfer base clock selection All of these bits are "0" UART0CR2 Selection of number of RT clocks Selection of RXD pin input noise rejection time Receive stop bit length Both of these bits are "0" -
UART0CR2 UART0CR2
-
-
Both of these bits are "0"
RA001
Page 214
TMP89FM42
16.5 Activation of STOP, IDLE0 or SLEEP0 Mode
16.5.1 Transition of register status
When the STOP, IDLE0 or SLEEP0 mode is activated, the UART stops automatically and each register becomes the status as shown in Table 16-4. For the registers that do not hold their values, make settings again as needed after the operation mode is recovered. Table 16-4 Transition of Register Status
7 TXE UART0CR1 Cleared to 0 UART0CR2 PERR UART0SR Cleared to 0 UART0DR7 UART0DR Hold the value RD0DR7 RD0BUF Indeterminate TD0DR7 TD0BUF Indeterminate FERR Cleared to 0 UART0DR6 Hold the value RD0DR6 Indeterminate TD0DR6 Indeterminate 6 RXE Cleared to 0 Hold the value OERR Cleared to 0 UART0DR5 Hold the value RD0DR5 Indeterminate TD0DR5 Indeterminate 5 STOPBT Hold the value 4 EVEN Hold the value RTSEL Hold the value UART0DR4 Hold the value RD0DR4 Indeterminate TD0DR4 Indeterminate Hold the value RBSY Cleared to 0 UART0DR3 Hold the value RD0DR3 Indeterminate TD0DR3 Indeterminate 3 PE Hold the value 2 IRDASEL Hold the value 1 BRG Hold the value 0 STOPBR Hold the value TBFL Cleared to 0 UART0DR0 Hold the value RD0DR0 Indeterminate TD0DR0 Indeterminate
RXDNC Hold the value RBFL Cleared to 0 UART0DR2 Hold the value RD0DR2 Indeterminate TD0DR2 Indeterminate Hold the value TBSY Cleared to 0 UART0DR1 Hold the value RD0DR1 Indeterminate TD0DR1 Indeterminate
16.5.2 Transition of TXD pin status
When the IDLE0, SLEEP0 or STOP mode is activated, the TXD pin reverts to the status shown in Table 165, whether data is transmitted/received or the operation is stopped. Table 16-5 TXD Pin Status When the STOP, IDLE0 or SLEEP0 Mode Is Activated
UART0CR1 "0" "1" STOP mode IDLE0 or SLEEP0 mode SYSCR1="1" H level L level H level Hi-Z L level SYSCR1="0"
RA001
Page 215
16. Asynchronous Serial Interface (UART)
16.6 Transfer Data Format TMP89FM42
16.6 Transfer Data Format
The UART transfers data composed of the following four elements. The data from the start bit to the stop bit is collectively defined as a "transfer frame". The start bit consists of 1 bit (L level) and the data consists of 8 bits. Parity bits are determined by UART0CR1 that selects the presence or absence of parity and UART0CR1 that selects even- or odd-numbered parity. The bit length of the stop bit can be selected at UART0CR1. Figure 16-2 shows the transfer data format. * Start bit (1 bit) * Data (8 bits) * Parity bit (selectable from even-numbered, odd-numbered or no parity) * Stop bit (selectable from 1 bit or 2 bits)
Transfer frame PE 0 0 1 1 STBT 0 1 0 1 1 Start Start Start Start 2 Bit 0 Bit 0 Bit 0 Bit 0 3 Bit 1 Bit 1 Bit 1 Bit 1 4 Bit 2 Bit 2 Bit 2 Bit 2 5 Bit 3 Bit 3 Bit 3 Bit 3 6 Bit 4 Bit 4 Bit 4 Bit 4 7 Bit 5 Bit 5 Bit 5 Bit 5 8 Bit 6 Bit 6 Bit 6 Bit 6 9 10 11 12
Bit 7 Stop 1 Bit 7 Stop 1 Stop 2 Bit 7 Parity Stop 1 Bit 7 Parity Stop 1 Stop 2
Figure 16-2 Transfer Data Format
16.7 Infrared Data Format Transfer Mode
The TXD0 pin can output data in the infrared data format (IrDA) by the setting of the IrDA output control register. Setting UART0CR1 to "1" allows the TXD0 pin to output data in the infrared data format.
Start bit UART output IrDA output D0 D1 D2 D7
Stop bit
3/16 Bit width
Figure 16-3 Example of Infrared Data Format (Comparison between Normal Output and IrDA Output)
RA001
Page 216
TMP89FM42
16.8 Transfer Baud Rate
The transfer baud rate of UART is set by UART0CR1, UART0DR and UART0CR2. Table 16-6 and Table 16-7 show the settings of UART0DR and UART0CR2 for general baud rates and operating frequencies. For independent calculation of transfer baud rates, refer to "16.8.1 Transfer baud rate calculation method". Table 16-6 Set Values of UART0DR and UART0CR2 for Transfer Baud Rates (fcgck=10 to 1 MHz, UART0CR2=0y00)
Basic baud rate [baud] Operating frequency Register 10MHz UART0DR 128000 RTSEL Error UART0DR 115200 RTSEL Error UART0DR 76800 RTSEL Error UART0DR 62500 RTSEL Error UART0DR 57600 RTSEL Error UART0DR 38400 RTSEL Error UART0DR 19200 RTSEL Error UART0DR 9600 RTSEL Error UART0DR 4800 RTSEL Error UART0DR 2400 RTSEL Error UART0DR 1200 RTSEL Error 0x04 0y011 (+0.81%) 0x04 0y100 (+2.12%) 0x07 0y001 (-1.36%) 0x09 0y000 (0%) 0x0A 0y000 (-1.36%) 0x10 0y011 (-1.17%) 0x22 0y010 (-0.79%) 0x40 0y000 (+0.16%) 0x8A 0y010 (-0.08%) 0xF4 0y100 (+0.04%) 8MHz 0x03 0y011 (+0.81%) 0x03 0y100 (+2.12%) 0x06 0y010 (-0.79%) 0x07 0y000 (0%) 0x08 0y011 (-0.44%) 0x0C 0y000 (+0.16%) 0x19 0y000 (+0.16%) 0x30 0y100 (+0.04%) 0x64 0y001 (+0.01%) 0xC9 0y001 (+0.01%) 7.3728 MHz 0x03 0y000 (0%) 0x05 0y000 (0%) 0x06 0y100 (-0.87%) 0x07 0y000 (0%) 0x0B 0y000 (0%) 0x17 0y000 (0%) 0x2F 0y000 (0%) 0x5F 0y000 (0%) 0xBF 0y000 (0%) 6.144 MHz 0x02 0y000 (0%) 0x04 0y000 (0%) 0x05 0y001 (-0.70%) 0x06 0y010 (+1.59%) 0x09 0y000 (0%) 0x13 0y000 (0%) 0x27 0y000 (0%) 0x4F 0y000 (0%) 0x9F 0y000 (0%) 6MHz 0x02 0y011 (+0.81%) 0x02 0y100 (+2.12%) 0x04 0y011 (+0.81%) 0x05 0y000 (0%) 0x06 0y010 (-0.79%) 0x09 0y011 (+0.81%) 0x12 0y001 (-0.32%) 0x26 0y000 (+0.16%) 0x4D 0y000 (+0.16%) 0x92 0y100 (+0.04%) 5MHz 0x03 0y001 (-1.36%) 0x04 0y000 (0%) 0x04 0y100 (+2.12%) 0x07 0y001 (-1.36%) 0x10 0y011 (-1.17%) 0x22 0y010 (-0.79%) 0x40 0y000 (+0.16%) 0x8A 0y010 (-0.08%) 0xF4 0y100 (+0.04%) 4.9152 MHz 0x03 0y000 (0%) 0x04 0y011 (+1.48%) 0x04 0y100 (+0.39%) 0x07 0y000 (0%) 0x0F 0y000 (0%) 0x1F 0y000 (0%) 0x3F 0y000 (0%) 0x7F 0y000 (0%) 0xFF 0y000 (+0%) 4.19MHz 0x01 0y001 (-0.80%) 0x03 0y100 (-1.41%) 0x06 0y011 (+0.57%) 0x0D 0y011 (+0.57%) 0x1C 0y010 (+0.34%) 0x34 0y001 (-0.18%) 0x6C 0y000 (+0.11%) 0xE8 0y010 (-0.10%) 4MHz 0x01 0y011 (+0.81%) 0x01 0y100 (+2.12%) 0x02 0y100 (+2.12%) 0x03 0y000 (0%) 0x03 0y100 (+2.12%) 0x06 0y010 (-0.79%) 0x0C 0y000 (+0.16%) 0x19 0y000 (+0.16%) 0x30 0y100 (+0.04%) 0x64 0y001 (+0.01%) 0xC9 0y001 (+0.01%) 2MHz 0x00 0y011 (+0.81%) 0x00 0y100 (+2.12%) 0x01 0y000 (0%) 0x01 0y100 (+2.12%) 0x02 0y100 (+2.12%) 0x06 0y010 (-0.79%) 0x0C 0y000 (+0.16%) 0x19 0y000 (+0.16%) 0x30 0y100 (+0.04%) 0x64 0y001 (+0.01%) 1MHz 0x00 0y000 (0%) 0x00 0y100 (+2.12%) 0x02 0y100 (+2.12%) 0x06 0y010 (-0.79%) 0x0C 0y000 (+0.16%) 0x19 0y000 (+0.16%) 0x30 0y100 (+0.04%)
RA001
Page 217
16. Asynchronous Serial Interface (UART)
16.8 Transfer Baud Rate TMP89FM42
Table 16-7 Set Values of UART0DR and UART0CR2 for Transfer Baud Rates (fs=32.768 kHz, UART0CR2=0y00)
Basic baud rate [baud] Operating frequency Register 32.768 kHz UART0DR 300 RTSEL Error UART0DR 150 RTSEL Error UART0DR 134 RTSEL Error UART0DR 110 RTSEL Error UART0DR 75 RTSEL Error 0x06 0y011 (+0.67%) 0x0D 0y011 (+0.67%) 0x0E 0y001 (-1.20%) 0x11 0y001 (+0.30%) 0x1C 0y010 (+0.44%)
Note 1: The overall error from the basic baud rate must be within 3%. Even if the overall error is within 3%, the communication may fail due to factors such as frequency errors in external controllers (for example, a personal computer) and oscillators and the load capacity of the communication pin.
16.8.1 Transfer baud rate calculation method
16.8.1.1 Bit width adjustment using UART0CR2
The bit width of transmitted/received data can be finely adjusted by changing UART0CR2. The number of RT clocks per bit can be changed in a range of 15 to 17 clocks by changing UART0CR2. The RT clock is the transfer base clock, which is the pulses obtained by counting the clock selected at UART0CR1 the number of times of (UART0DR set value) + 1. Especially, when UART0CR2 is set to "0y001" or "0y011", two types of RT clocks alternate at each bit, so that the pseudo baud rates of RT x 15.5 clocks and RT x 16.5 clocks can be generated. The number of RT clocks per bit of transfer frame is shown in Figure 16-4. For example, when fcgck is 4 [MHz], UART0CR2 is set to "0y000" and UART0DR is set to "0x19", the baud rate calculated using the formula in Figure 16-4 is expressed as: fcgck / (16 x (UART0DR + 1) = 9615 [baud] These settings generate a baud rate close to 9600 [baud] (+0.16%).
RA001
Page 218
TMP89FM42
Transfer frame PE 0 0 1 1 STBT 0 1 0 1 1 Start Start Start Start 2 Bit 0 Bit 0 Bit 0 Bit 0 3 Bit 1 Bit 1 Bit 1 Bit 1 4 Bit 2 Bit 2 Bit 2 Bit 2 5 Bit 3 Bit 3 Bit 3 Bit 3 6 Bit 4 Bit 4 Bit 4 Bit 4 7 Bit 5 Bit 5 Bit 5 Bit 5 8 Bit 6 Bit 6 Bit 6 Bit 6 9 10 11 12
Bit 7 Stop 1 Bit 7 Stop 1 Stop 2 Bit 7 Parity Stop 1 Bit 7 Parity Stop 1 Stop 2
RTSEL 000 001 010 011 100 16 16 15 15 17 16 17 15 16 17 16 16 15 15 17 16 17 15 16 17
Number of RT clocks 16 16 15 15 17 16 17 15 16 17 16 16 15 15 17 16 17 15 16 17 16 16 15 15 17 16 17 15 16 17 16 16 15 15 17 16 17 15 16 17
Generated baud rate
16 16.5 15 15.5 17 fcgck (UARTDR+1) fcgck (UARTDR+1) fcgck (UARTDR+1) fcgck (UARTDR+1) fcgck (UARTDR+1) [baud] [baud] [baud] [baud] [baud]
*When BRG is set to fcgck
Figure 16-4 Fine Adjustment of Baud Rate Clock Using UART0CR2
16.8.1.2 Calculation of set values of UART0CR2 and UART0DR
The set value of UART0DR for an operating frequency and baud rate can be calculated using the calculation formula shown in Figure 16-5. For example, to generate a basic baud rate of 38400 [baud] with fcgck=4 [MHz], calculate the set value of UART0DR for each setting of UART0CR2 and compensate the calculated value to a positive number to obtain the generated baud rate as shown in Figure 166. Basically, select the set value of UART0CR2 that has the smallest baud rate error from among the generated baud rates. In Figure 16-6, the setting of UART0CR2="0y010" has the smallest error among the calculated baud rates, and thus the generated baud rate is 38095 [baud] (-0.79%) against the basic baud rate of 38400 [baud].
Note: The error from the basic baud rate should be accurate to within 3%. Even if the error is within 3%, the communication may fail due to factors such as frequency errors of external controllers (for example, a personal computer) and oscillators and the load capacity of the communication pin.
RTSEL 000 001 010 011 100
UARTDR set value UARTDR = UARTDR = UARTDR = UARTDR = UARTDR = fcgck [Hz] 16 A [baud] fcgck [Hz] 16.5 A [baud] fcgck [Hz] 15 A [baud] fcgck [Hz] 15.5 A [baud] fcgck [Hz] 17 A [baud] 1 1 1 1 1
Figure 16-5 UART0DR Calculation Method (When BRG Is Set to fcgck)
RA001
Page 219
16. Asynchronous Serial Interface (UART)
16.8 Transfer Baud Rate TMP89FM42
RTSEL 000 001 010 011 100
UARTDR calculation UARTDR = UARTDR = UARTDR = UARTDR = UARTDR = 4000000 [Hz] 16 38400 [baud] 4000000 [Hz] 16.5 38400 [baud] 4000000 [Hz] 15 38400 [baud] 4000000 [Hz] 15.5 38400 [baud] 4000000 [Hz] 17 38400 [baud] 1 1 1 1 1
Generated baud rate
6 5 6 6 5
4000000 [Hz] 16 (6 + 1) 4000000 [Hz] 16.5 (5 + 1) 4000000 [Hz] 15 (6 + 1) 4000000 [Hz] 15.5 (6 + 1) 4000000 [Hz] 17 (5 + 1)
35714 [baud] ( 6.99%) 40404 [baud] ( 5.22%) 38095 [baud] ( 0.79%) 36866 [baud] ( 3.99%) 39216 [baud] ( 2.12%)
Figure 16-6 Example of UART0DR Calculation
RA001
Page 220
TMP89FM42
16.9 Data Sampling Method
The UART receive control circuit starts RT clock counting when it detects a falling edge of the input pulses to the RXD0 pin. 15 to 17 RT clocks are counted per bit and each clock is expressed as RTn (n=16 to 0). In a bit that has 17 RT clocks, RT16 to RT0 are counted. In a bit that has 16 RT clocks, RT15 to RT0 are counted. In a bit that has 15 RT clocks, RT14 to RT0 are counted (Decrement). During counting of RT8 to RT6, the UART receive control circuit samples the input pulses to the RXD0 pin to make a majority decision. The same level detected twice or more from among three samplings is processed as the data for the bit. The number of RT clocks can be changed in a range of 15 to 17 by setting UART0CR2. However, sampling is always executed in RT8 to RT6, even if the number of RT clocks is changed (Figure 16-7).
RXD0 pin
Start Bit RT15 14 13 12 11 10 9 8 7 6 5 4 32
Bit 0 1 0 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 15 14 13
RT clock
Internal received data
Start Bit
Bit 0 (a) UARTCR2 is "000B"
RXD0 pin
Start Bit RT15 14 13 12 11 10 9 8 7 6 5 4 32
Bit 0 1 0 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 15 14
RT clock
Internal received data
Start Bit
Bit 0 (b) UARTCR2 is "001B"
RXD0 pin
Start Bit RT14 13 12 11 10 9 8 7 6 5 4 3 21
Bit 0 0 14 13 12 11 10 9 8 7 6 5 4 3 2 1
Bit 1 0 14 13 12 11 10
RT clock
Internal received data
Start Bit
Bit 0 (c) UARTCR2 is "010B"
Bit 1
RXD0 pin
Start Bit RT14 13 12 11 10 9 8 7 6 5 4 3 21
Bit 0 0 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
Bit 1 0 14 13 12 11
RT clock
Internal received data
Start Bit
Bit 0 (d) UARTCR2 is "011B"
Bit 1
RXD0 pin
Start Bit RT16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
Bit 0 0 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 16
RT clock
Internal received data
Start Bit
Bit 0 (e) UARTCR2 is "100B"
Figure 16-7 Data Sampling in Each Case of UARTCR2
RA001
Page 221
16. Asynchronous Serial Interface (UART)
16.9 Data Sampling Method TMP89FM42
If "1" is detected in sampling of the start bit, for example, due to the influence of noise, RT clock counting stops and the data receiving is suspended. Subsequently, when a falling edge is detected in the input pulses to the RXD0 pin, RT clock counting restarts and the data receiving restarts with the start bit.
Counting is suspended until the next falling edge is detected RT15 14 13 12 11 10 9 RT clock Noise RXD0 pin Start Bit Bit 0 8 76 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 15 14 13 12 11 10 9 8 7 6 5 4 3
Internal received data Shift register A falling edge is detected
Start Bit
Bit 0
Bit 0 A falling edge is detected The received data is taken into the shift register
Error because the start bit is 1
Receiving continues because the start bit is 0
Figure 16-8 Start Bit Sampling
RA001
Page 222
TMP89FM42
16.10Received Data Noise Rejection
When noise rejection is enabled at UART0CR2, the time of pulses to be regarded as signals is as shown in Table 16-8. Table 16-8 Received Data Noise Rejection Time
RXDNC 00 01 10 11 Noise rejection time [s] No noise rejection (UART0DR+1)/(Transfer base clock frequency) 2 x (UART0DR+1)/(Transfer base clock frequency) 4 x (UART0DR+1)/(Transfer base clock frequency) Time of pulses to be regarded as signals 2 x (UART0DR+1)/(Transfer base clock frequency) 4 x (UART0DR+1)/(Transfer base clock frequency) 8 x (UART0DR+1)/(Transfer base clock frequency)
Note 1: The transfer base clock frequency is the clock frequency selected at UARTCR1.
15 14 13 12 11 10 9 RT clock Noise RXD0 pin Start bit
8
7
6
5
4
3
2
1
0 15 14 13 12 11 10 9
8
7
6
5
4
3
Bit 0
Internal received data Shift register
Noise is removed
Start bit
Bit 0
Bit 0 A falling edge is detected The received data is taken into the shift register
Receiving continues because the start bit is 0
When the noise rejection circuit is used
Figure 16-9 Received Data Noise Rejection
RA001
Page 223
16. Asynchronous Serial Interface (UART)
16.11 Transmit/Receive Operation TMP89FM42
16.11Transmit/Receive Operation
16.11.1Data transmit operation
Set UART0CR1 to "1". Check UART0SR = "0", and then write data into TD0BUF (transmit data buffer). Writing data into TD0BUF sets UART0SR to "1", transfers the data to the transmit shift register, and outputs the data sequentially from the TXD0 pin. The data output includes a start bit, stop bits whose number is specified in UART0CR1 and a parity bit if parity addition is specified. Select the data transfer baud rate using UART0CR1, UART0CR2 and UART0DR. When data transmission starts, the transmit buffer full flag UART0SR is cleared to "0" and an INTTXD0 interrupt request is generated.
Note 1: After data is written into TD0BUF, if new data is written into TD0BUF before the previous data is transferred to the shift register, the new data is written over the previous data and is transferred to the shift register. Note 2: Under the conditions shown in Table 16-9, the TXD0 pin output is fixed at the L or H level according to the setting of UART0CR1.
Table 16-9 TXD0 Pin Output
TXD0 pin output Condition IRDASEL="0" When UART0CR1 is "0" From when "1" is written to UART0CR1 to when the transmitted data is written to TD0BUF When the STOP, IDLE0 or SLEEP0 mode is active IRDASEL="1"
H level
L level
16.11.2Data receive operation
Set UART0CR1 to "1". When data is received via the RXD0 pin, the received data is transferred to RD0BUF (receive data buffer). At this time, the transmitted data includes a start bit, stop bit(s) and a parity bit if parity addition is specified. When the stop bit(s) are received, data only is extracted and transferred to RD0BUF (receive data buffer). Then the receive buffer full flag UART0SR is set and an INTRXD0 interrupt request is generated. Set the data transfer baud rate using UART0CR1, UART0CR2 and UART0DR. If an overrun error occurs when data is received, the data is not transferred to RD0BUF (receive data buffer) but discarded; data in the RD0BUF is not affected.
RA001
Page 224
TMP89FM42
16.12Status Flag
16.12.1Parity error
When the parity determined using the receive data bits differs from the received parity bit, the parity error flag UART0SR is set to "1". At this time, an INTRXD0 interrupt request is generated. If UART0SR is "1" when UART0SR is read, UART0SR will be cleared to "0" when RD0BUF is read subsequently. (The RD0BUF read value becomes undefined.) If UART0SR is set to "1" after UART0SR is read, UART0SR will not be cleared to "0" when RD0BUF is read subsequently. In this case, UART0SR will be cleared to "0" when UART0SR is read again and RD0BUF is read.
RXD0 pin input UART0SR INTRXD0 interrupt request Reading of UART0SR Reading of RD0BUF RD0BUF
Start Bit0
Bit1
Bit2
Bit3
Bit4
Bit5
Bit6
Bit7 Parity Stop
PERR is cleared to "0" when RD0BUF is read after reading PERR="1".
Indeterminate Data reading
RXD0 pin input UART0SR INTRXD0 interrupt request Reading of UART0SR Reading of RD0BUF RD0BUF
Start Bit0
Bit1
Bit2
Bit3
Bit4
Bit5
Bit6
Bit7 Parity Stop
Not cleared PERR is cleared to "0" when RD0BUF is read after reading PERR="1".
Indeterminate
Data reading
Data reading
Figure 16-10 Occurrence of Parity Error
RA001
Page 225
16. Asynchronous Serial Interface (UART)
16.12 Status Flag TMP89FM42
16.12.2Framing Error
If the internal and external baud rates differ or "0" is sampled as the stop bit of received data due to the influence of noise on the RXD0 pin, the framing error flag UART0SR is set to "1". At this time, an INTRXD0 interrupt request is generated. If UART0SR is "1" when UART0SR is read, UART0SR will be cleared to "0" when RD0BUF is read subsequently. If UART0SR is set to "1" after UART0SR is read, UART0SR will not be cleared to "0" when RD0BUF is read subsequently. In this case, UART0SR will be cleared to "0" when UART0SR is read again and RD0BUF is read.
A falling edge is detected
RXD0 pin input Sampling UART0SR
Start Bit0
Bit1
Bit2
Bit3
Bit4
Bit5
Bit6
Bit7 Stop FERR is generated if "0" is received in the sampling of the stop bit.
Start Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 Stop
INTRXD0 interrupt request Reading of UART0SR Reading of RD0BUF RD0BUF
FERR is cleared to "0" when RD0BUF is read after reading FERR="1".
Indeterminate Data reading
When the external baud rate is slower than the internally set baud rate
A falling edge is detected A falling edge is detected Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 Stop Start Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 Stop
RXD0 pin input Sampling
Start Bit0
Bit1
Start
Bit0
Bit1
Bit2
Bit3
Bit4
Bit5
Bit6
Bit7
Stop
Start
Bit0
Bit1
Bit2
Bit3
Bit4
Bit5
UART0SR
FERR is generated if "0" is received in the sampling of the stop bit. FERR is cleared to "0" when RD0BUF is read after reading FERR="1".
INTRXD0 interrupt request Reading of UART0SR Reading of RD0BUF RD0BUF
Indeterminate Data reading
When the external baud rate is faster than the internally set baud rate
Figure 16-11 Occurrence of Framing Error
RA001
Page 226
TMP89FM42
16.12.3Overrun error
If receiving of all data bits is completed before the previous received data is read from RD0BUF, the overrun error flag UART0SR is set to "1" and an INTRXD0 interrupt request is generated. The data received at the occurrence of the overrun error is discarded and the previous received data is maintained. Subsequently, if data is received while UART0SR is still "1", no INTRXD0 interrupt request is generated, and the received data is discarded. (Figure 16-12) Note that parity or framing errors in the discarded received data cannot be detected. (These error flags are not set.) That is to say, if these errors are detected together with an overrun error during the reading of UART0SR, they have occurred in the previous received data (the data stored in RD0BUF). (Figure 16-13) If UART0SR is "1" when UART0SR is read, UART0SR will be cleared to "0" when RD0BUF is read subsequently. (Figure 16-14) If UART0SR is set to "1" after UART0SR is read, UART0SR will not be cleared to "0" when RD0BUF is read subsequently. In this case, UART0SR will be cleared to "0" when UART0SR is read again and RD0BUF is read. (Figure 16-14)
Data A Data B Data C
RXD0 pin input UART0SR UART0SR
Start Bit0
Bit1
Bit7 Stop Start Bit0
Bit1
Bit7 Stop Start Bit0
Bit1
Bit7 Stop
The flag is set. No interrupt request is generated.
INTRXD0 interrupt request RD0BUF
An interrupt request is generated.
An interrupt request is generated.
Data A The contents of data B are discarded and those of data A are maintained. The contents of data C are discarded and those of data A are maintained.
Figure 16-12 Generation of INTRXD0 Interrupt Request
RA001
Page 227
16. Asynchronous Serial Interface (UART)
16.12 Status Flag TMP89FM42
Data A
Data B
Data C
Data D
RXD0 pin input UART0SR UART0SR UART0SR UART0SR
Start Bit0
Parity Stop Start Bit0
Parity Stop The parity is OK.
Start Bit0
Parity Stop Start Bit0
Parity Stop
A parity error occurs.
The flag is not set even if a framing error occurs.
The flag is set.
INTRXD0 interrupt request RD0BUF
An interrupt request is generated.
An interrupt request is generated.
No interrupt request is generated.
Data A The contents of data B are discarded and those of data A are maintained. The contents of data C are discarded and those of data A are maintained. The contents of data D are discarded and those of data A are maintained.
When a parity error occurs in the first received data and a framing error occurs in the second data
Data A
Data B
Data C
Data D
RXD0 pin input UART0SR UART0SR UART0SR
Start Bit0
Parity Stop Start Bit0
Parity Stop Start Bit0
Parity Stop Start Bit0
Parity Stop
The parity is OK.
A parity error occurs.
The error flag is not set together with an overrun error.
INTRXD0 interrupt request RD0BUF
An interrupt request is generated.
An interrupt request is generated.
No interrupt request is generated.
Data A The contents of data B are discarded and those of data A are maintained. The contents of data C are discarded and those of data A are maintained. The contents of data D are discarded and those of data A are maintained.
When a parity error occurs in the second received data
Figure 16-13 Framing/Parity Error Flags When an Overrun Error Occurs
RA001
Page 228
TMP89FM42
Data A
Data B
RXD0 pin input UART0SR UART0SR
Start Bit0
Bit1
Bit7 Stop Start Bit0
Bit1
Bit7 Stop
RBFL is cleared to "0" when RD0BUF is read after reading RBFL="1". OERR is cleared to "0" when RD0BUF is read after reading OERR="1".
INTRXD0 interrupt request Reading of UART0SR Reading of RD0BUF RD0BUF
Data A The contents of data B are discarded and those of data A are maintained. Reading of data A
Data A
Data B
RXD0 pin input UART0SR UART0SR
Start Bit0
Bit1
Bit7 Stop Start Bit0
Bit1
Bit7 Stop RBFL is cleared to "0" when RD0BUF is read after reading RBFL="1".
INTRXD0 interrupt request Reading of UART0SR Reading of RD0BUF RD0BUF
OERR is cleared to "0" when RD0BUF is read after reading OERR="1".
Data A The contents of data B are discarded and those of data A are maintained. Reading of data A Reading of data A
Figure 16-14 Clearance of Overrun Error Flag
RA001
Page 229
16. Asynchronous Serial Interface (UART)
16.12 Status Flag TMP89FM42
16.12.4Receive Data Buffer Full
Loading the received data in RD0BUF sets UART0SR to "1". If UART0SR is "1" when UART0SR is read, UART0SR will be cleared to "0" when RD0BUF is read subsequently. If UART0SR is set to "1" after UART0SR is read, UART0SR will not be cleared to "0" when RD0BUF is read subsequently. In this case, UART0SR will be cleared to "0" when UART0SR is read again and RD0BUF is read.
Data A Data B
RXD0 pin input UART0SR INTRXD0 interrupt request Reading of UART0SR Reading of RD0BUF RD0BUF
Start Bit1
Bit0
Bit7 Stop Start Bit0
Bit1
Bit7 Stop
RBFL is cleared to "0" when RD0BUF is read after reading RBFL="1".
Data A Reading of data A
Data B Reading of data B
Figure 16-15 Occurrence of Receive Data Buffer Full
RA001
Page 230
TMP89FM42
16.12.5 Transmit busy flag
If transmission is completed with no waiting data in TD0BUF (when UART0SR="0"), UART0SR is cleared to "0". When transmission is restarted after data is written into TD0BUF, UART0SR is set to "1". At this time, an INTTXD0 interrupt request is generated.
UART0CR1 TXD0 pin input UART0SR UART0SR INTTXD0 interrupt request Writing of TD0BUF
Writing of data A Start Bit0 Bit1 Bit2
Data A Bit3 Bit4 Bit5 Bit6 Bit7 Stop Start Bit0
Data B Bit1 Bit6 Bit7 Stop
Writing of data B
Figure 16-16 Transmit Busy Flag and Occurrence of Transmit Buffer Full
16.12.6Transmit Buffer Full
When TD0BUF has no data, or when data in TD0BUF is transferred to the transmit shift register and transmission is started, UART0SR is cleared to "0". At this time, an INTTXD0 interrupt request is generated. Writing data into TD0BUF sets UART0SR to "1".
UART0CR1 TXD0 pin input UART0SR UART0SR INTTXD0 interrupt request Writing of TD0BUF
Writing of data A Writing of data B Start Bit0 Bit1 Bit2
Data A Bit3 Bit4 Bit5 Bit6 Bit7 Stop Start Bit0 Bit1 Bit2
Data B Bit3 Bit6 Bit7 Stop
Figure 16-17 Occurrence of Transmit Buffer Full
RA001
Page 231
16. Asynchronous Serial Interface (UART)
16.13 Receiving Process TMP89FM42
16.13Receiving Process
Figure 16-18 shows an example of the receiving process. Details of flag judgments in the processing are shown in Table 16-10 and Table 16-11. If any framing error or parity error is detected, the received data has erroneous value(s). Execute the error handling, for example, by discarding the received data read from RD0BUF and receiving the data again. If any overrun error is detected, the receiving of one or more pieces of data is unfinished. It is impossible to determine the number of pieces of data that could not be received. Execute the error handling, for example, by receiving data again from the beginning of the transfer. Basically, an overrun error occurs when the internal software processing cannot follow the data transfer speed. It is recommended to slow the transfer baud rate or modify the software to execute flow control.
INTRXD0 interrupt subroutine Read UART0SR
Receiving process
Read UART0SR
Read RD0BUF
Read RD0BUF
UART0SR 1 UART0SR 0 UART0SR 0 Data processing (Received data is valid)
0
1 Parity error
UART0SR 0
1 Parity error
1 Framing error
UART0SR 0 Data processing (Received data is valid)
1 Framing error
Error handling
Error handling
UART0SR 0
1 Overrun error Error handling
UART0SR 0
1 Overrun error Error handling
END
RETI
When no receive interrupt is used
When a receive interrupt is used
Figure 16-18 Example of Receiving Process
Note 1: If multiple interrupts are used in the INTRXD0 interrupt subroutine, the interrupt should be enabled after reading UART0SR and RD0BUF.
RA001
Page 232
TMP89FM42
Table 16-10 Flag Judgments When No Receive Interrupt Is Used
RBFL 0 FERR/PERR OERR 0 State Data has not been received yet. Some pieces of data could not be received during the previous data receiving process (Receiving of next data is completed in the period from when UART0SR is read to when RD0BUF is read in the previous data receiving process.) Receiving has been completed properly. Receiving has been completed properly, but some pieces of data could not be received. Received data has erroneous value(s). Received data has erroneous value(s) and some pieces of data could not be received.
0
-
1
1 1 1 1
0 0 1 1
0 1 0 1
Table 16-11 Flag Judgments When a Receive Interrupt Is Used
FERR/PERR 0 0 1 1 OERR 0 1 0 1 State Receiving has been completed properly. Receiving has been completed properly, but some pieces of data could not be received. Received data has erroneous value(s). Received data has erroneous value(s) and some pieces of data could not be received.
RA001
Page 233
16. Asynchronous Serial Interface (UART)
16.14 AC Properties TMP89FM42
16.14AC Properties
16.14.1IrDA properties
(VSS = 0 V, Topr = -40 to 85C) Item Condition Transfer baud rate = 2400 bps Transfer baud rate = 9600 bps TXD output pulse time (RT clock x (3/16)) Transfer baud rate = 19200 bps Transfer baud rate = 38400 bps Transfer baud rate = 57600 bps Transfer baud rate = 115200 bps Min - - - - - - Typ. 78.13 19.53 9.77 4.88 3.26 1.63 Max - - - - - - s Unit
RA001
Page 234
TMP89FM42
16.15Revision History
Rev Revised Table 16-6.
Description
RA001
"16.8.1.1 Bit width adjustment using UART0CR2" Changed example from fcgck=8MHz to fcgck=4MHz. "16.8.1.2 Calculation of set values of UART0CR2 and UART0DR" Changed example from fcgck=6MHz to fcgck=4MHz. "Figure 16-6 Example of UART0DR Calculation" Changed example from fcgck=6MHz to fcgck=4MHz. "Figure 16-1 Asynchronous Serial Interface (UART)" Added PPGA0 output to TCA0 output.
RA001
Page 235
16. Asynchronous Serial Interface (UART)
16.15 Revision History TMP89FM42
RA001
Page 236
TMP89FM42
17. Synchronous Serial Interface (SIO)
The TMP89FM42 contains 1 channel of high-speed 8-bit serial interfaces of the clock synchronization type. Table 17-1 SFR Address Assignment
SIOxCR (address) Serial interface 0 SIO0CR (0x001F) SIOxSR (address) SIO0SR (0x0020) SIOxBUF (address) SIO0BUF (0x0021)
Table 17-2 Pin Names
Serial clock input/output pin Serial interface 0 SCLK0 pin Serial data input pin SI0 pin Serial data output pin SO0 pin
RA001
Page 237
17. Synchronous Serial Interface (SIO)
17.1 Configuration TMP89FM42
17.1 Configuration
Internal bus INTSIO0 interrupt request SIO0CR SIO0SR SIO0BUF
Shift register on transmitter
Shift clock Internal clock
Control circuit
MSB/LSB selection
Port (Note) Port (Note)
SO0 pin SI0 pin
Shift register on receiver
SIO0BUF
Port (Note)
SCLK0 pin
Internal bus
Figure 17-1 Serial Interface
Note: The serial interface input/output pins are also used as the I/O ports. The I/O port register settings are required to use these pins for a serial interface. For details, refer to the chapter of I/O ports.
RA001
Page 238
TMP89FM42
17.2 Control
The synchronous serial interface SIO0 is controlled by the low power consumption registers (POFFCR2), the serial interface data buffer register (SIO0BUF), the serial interface control register (SIO0CR) and the serial interface status register (SIO0SR). Low power consumption register 2
POFFCR2 (0x0F76) Bit Symbol Read/Write After reset 7 R/W 0 6 R/W 0 5 RTCEN R/W 0 4 R/W 0 3 R/W 0 2 R/W 0 1 R/W 0 0 SIO0EN R/W 0
RTCEN
RTC control
0 1 0 1
Disable Enable Disable Enable
SIO0EN
SIO0 control
Serial interface buffer register
SIO0BUF (0x0021) Bit Symbol Read/Write After reset 0 0 0 0 7 6 5 4 SIO0BUF R 0 0 0 0 3 2 1 0
Serial interface buffer register
SIO0BUF (0x0021) Bit Symbol Read/Write After reset 1 1 1 1 7 6 5 4 SIO0BUF W 1 1 1 1 3 2 1 0
Note 1: SIO0BUF is the data buffer for both transmission and reception. The last received data is read each time SIO0BUF is read. If SIO0BUF has never received data, it is read as "0". When data is written into it, the data is treated as the transmit data.
RA001
Page 239
17. Synchronous Serial Interface (SIO)
17.2 Control TMP89FM42
Serial interface control register
SIO0CR (0x001F) Bit Symbol Read/Write After reset 7 SIOEDG R/W 0 0 6 5 SIOCKS R/W 0 0 4 3 SIODIR R/W 0 2 SIOS R/W 0 0 1 SIOM R/W 0 0
SIOEDG
Transfer edge selection
0 1
0: Receive data at a rising edge and transmit data at a falling edge 1: Transmit data at a rising edge and receive data at a falling edge NORMAL1/2 or IDLE1/2 mode SLOW1/2 or SLEEP1 mode fs/23 External clock input LSB first (transfer from bit 0) MSB first (transfer from bit 7) 0: Operation stop (reserved stop) 1: Operation start Operation stop (forced stop) 8-bit transmit mode 8-bit receive mode 8-bit transmit and receive mode
000 001 010 SIOCKS Serial clock selection [Hz] 011 100 101 110 111 SIODIR Transfer format (MSB/LSB) selection Transfer operation start/stop instruction 0 1 0 1 00 SIOM Transfer mode selection and operation 01 10 11
fcgck/29 fcgck/26 fcgck/25 fcgck/24 fcgck/23 fcgck/2
2
fcgck/2
SIOS
Note 1: fcgck: Gear clock [Hz], fs: Low-frequency clock [Hz] Note 2: After the operation is started by writing "1" to SIOS, writing to SIOEDG, SIOCKS and SIODIR is invalid until SIO0SR becomes "0". (SIOEDG, SIOCKS and SIODIR can be changed at the same time as changing SIOS from "0" to "1".) Note 3: After the operation is started by writing "1" to SIOS, no values other than"00" can be written to SIOM until SIOF becomes "0" (if a value from "01" to "11" is written to SIOM, it is ignored). The transfer mode cannot be changed during the operation. Note 4: SIOS remains at "0", if "1" is written to SIOS when SIOM is "00" (operation stop). Note 5: When SIO is used in SLOW1/2 or SLEEP1 mode, be sure to set SIOCKS to "110". If SIOCKS is set to any other value, SIO will not operate. When SIO is used in SLOW1/2 or SLEEP1 mode, execute communications with SIOCKS="110" in advance or change SIOCKS after SIO is stopped. Note 6: When STOP, IDLE0 or SLEEP0 mode is activated, SIOM is automatically cleared to "00" and SIO stops the operation. At the same time, SIOS is cleared to "0". However, the values set for SIOEDG, SIOCKS and SIODIR are maintained.
RA001
Page 240
TMP89FM42
Serial interface status register
SIO0SR (0x0020) Bit Symbol Read/Write After reset 7 SIOF R 0 6 SEF R 0 5 OERR R 0 4 REND R 0 3 UERR R 0 2 TBFL R 0 1 R 0 0 R 0
SIOF
Serial transfer operation status monitor Shift operation status monitor
0 1 0 1 0 1 0 1 0 1 0 1
Transfer not in progress Transfer in progress Shift operation not in progress Shift operation in progress No overrun error has occurred At least one overrun error has occurred No data has been received since the last receive data was read out At least one data receive operation has been executed No transmit underrun error has occurred At least one transmit underrun error has occurred The transmit buffer is empty The transmit buffer has the data that has not yet been transmitted
SEF
OERR
Receive overrun error flag
REND
Receive completion flag
UERR
Transmit underrun error flag
TBFL
Transmit buffer full flag
Note 1: The OERR and UERR flags are cleared by reading SIO0SR. Note 2: The REND flag is cleared by reading SIO0BUF. Note 3: Writing "00" to SIO0CR clears all the bits of SIO0SR to "0", whether the serial interface is operating or not. When STOP, IDLE0 or SLEEP0 mode is activated, SIOM is automatically cleared to "00" and all the bits of SIO0SR are cleared to "0". Note 4: Bit 1 to 0 of SIO0SR are read "0".
RA001
Page 241
17. Synchronous Serial Interface (SIO)
17.3 Low Power Consumption Function TMP89FM42
17.3 Low Power Consumption Function
Serial interface 0 has the low power consumption registers (POFFCR2) that save power when the serial interface is not being used. Setting POFFCR2 to "0" disables the basic clock supply to serial interface 0 to save power. Note that this renders the serial interface unusable. Setting POFFCR2 to "1" enables the basic clock supply to serial interface 0 and allows the serial interface to operate. After reset, POFFCR2 are initialized to "0", and this renders the serial interface unusable. When using the serial interface for the first time, be sure to set POFFCR2 to "1" in the initial setting of the program (before the serial interface control registers are operated). Do not change POFFCR2 to "0" during the serial interface operation. Otherwise serial interface 0 may operate unexpectedly.
RA001
Page 242
TMP89FM42
17.4 Functions
17.4.1 Transfer format
The transfer format can be set to either MSB or LSB first by using SIO0CR. Setting SIO0CR to "0" selects LSB first as the transfer format. In this case, the serial data is transferred in sequence from the least significant bit. Setting SIO0CR to "1" selects MSB first as the transfer format. In this case, the serial data is transferred in sequence from the most significant bit.
17.4.2 Serial clock
The serial clock can be selected by using SIO0CR. Setting SIO0CR to "000" to "110" selects the internal clock as the serial clock. In this case, the serial clock is output from the SCLK0 pin. The serial data is transferred in synchronization with the edge of the SCLK0 pin output. Setting SIO0CR to "111" selects an external clock as the serial clock. In this case, an external serial clock must be input to the SCLK0 pin. The serial data is transferred in synchronization with the edge of the external clock. The serial data transfer edge can be selected for both the external and internal clocks. For details, refer to "17.4.3 Transfer edge selection". Table 17-3 Transfer Baud Rate
Serial clock [Hz] SIO0CR NORMAL1/2 or IDLE1/2 mode fcgck/29 fcgck/26 fcgck/25 fcgck/24 fcgck/23 fcgck/22 fcgck/2 SLOW1/2 or SLEEP1 mode fs/23 fcgck=4MHz 1-bit time (s) 128 16 8 4 2 1 0.5 Baud rate (bps) 7.813k 62.5k 125k 250k 500k 1M 2M fcgck=8MHz 1-bit time (s) 64 8 4 2 1 0.5 0.25 Baud rate (bps) 15.625k 125k 250k 500k 1M 2M 4M fcgck=10MHz 1-bit time (s) 51.2 6.4 3.2 1.6 0.8 0.4 0.2 Baud rate (bps) 19.531k 156.25k 312.5k 625k 1.25M 2.5M 5M fs=32.768kHz 1-bit time (s) 244 Baud rate (bps) 4k
000 001 010 011 100 101 110
17.4.3 Transfer edge selection
The serial data transfer edge can be selected by using SIOCR. Table 17-4 Transfer Edge Selection
SIO0CR 0 1 Data transmission Falling edge Rising edge Data reception Rising edge Falling edge
When SIOCR is "0", the data is transmitted in synchronization with the falling edge of the clock and the data is received in synchronization with the rising edge of the clock. When SIOCR is "1", the data is transmitted in synchronization with the rising edge of the clock and the data is received in synchronization with the falling edge of the clock.
RA001
Page 243
17. Synchronous Serial Interface (SIO)
17.4 Functions TMP89FM42
SLCK0 pin SO0 pin SI0 pin T0 T1 T2 T3 T4 T5 T6 T7
R0 R1 R2 R3 R4 R5 R6 R7 When SIOCR="0"
SCLK0 pin SO0 pin SI0 pin T0 T1 T2 T3 T4 T5 T6 T7
R0 R1 R2 R3 R4 R5 R6 R7 When SIOCR="1"
Figure 17-2 Transfer Edge
Note:When an external clock input is used, 4/fcgck or longer is needed between the receive edge at the 8th bit and the transfer edge at the first bit of the next transfer.
tBI SCLK0 pin SO0 pin SI0 pin A6 C6 A7 C7 B0 D0 B1 D1 B2 D2 Trailing edge at the Leading edge at the 8th bit (receive edge) 1st bit (transmit edge)
Symbol tBI Name Interval time between bytes Minimum time 4/fcgck
RA001
Page 244
TMP89FM42
17.5 Transfer Modes
17.5.1 8-bit transmit mode
The 8-bit transmit mode is selected by setting SIO0CR to "01".
17.5.1.1 Setting
Before starting the transmit operation, select the transfer edges at SIO0CR, a transfer format at SIO0CR and a serial clock at SIO0CR. To use the internal clock as the serial clock, select an appropriate serial clock at SIO0CR. To use an external clock as the serial clock, set SIO0CR to "111". The 8-bit transmit mode is selected by setting SIO0CR to "01". The transmit operation is started by writing the first byte of transmit data to SIO0BUF and then setting SIO0CR to "1". Writing data to SIO0CR is invalid when the serial communication is in progress, or when SIO0SR is "1". Make these settings while the serial communication is stopped. While the serial communication is in progress (SIO0SR="1"), only writing "00" to SIO0CR or writing "0" to SIO0CR is valid.
17.5.1.2 Starting the transmit operation
The transmit operation is started by writing data to SIO0BUF and then setting SIO0CR to "1". The transmit data is transferred from SIO0BUF to the shift register, and then transmitted as the serial data from the SO0 pin according to the settings of SIO0CR. The serial data becomes undefined if the transmit operation is started without writing any transmit data to SIO0BUF. In the internal clock operation, the serial clock of the selected baud rate is output from the SCLK0 pin. In the external clock operation, an external clock must be supplied to the SCLK0 pin. By setting SIO0CR to "1", SIO0SR are automatically set to "1" and an INTSIO0 interrupt request is generated. SIO0SR is cleared to "0" when the 8th bit of the serial data is output.
17.5.1.3 Transmit buffer and shift operation
If data is written to SIO0BUF when the serial communication is in progress and the shift register is empty, the written data is transferred to the shift register immediately. At this time, SIO0SR remains at "0". If data is written to SIO0BUF when some data remains in the shift register, SIO0SR is set to "1". If new data is written to SIO0BUF in this state, the contents of SIO0BUF are overwritten by the new value. Make sure that SIO0SR is "0" before writing data to SIO0BUF.
17.5.1.4 Operation on completion of transmission
The operation on completion of the data transmission varies depending on the operating clock and the state of SIO0SR.
RA001
Page 245
17. Synchronous Serial Interface (SIO)
17.5 Transfer Modes TMP89FM42
(1)
When the internal clock is used and SIO0SR is "0" When the data transmission is completed, the SCLK0 pin becomes the initial state and the SO0 pin becomes the "H" level. SIO0SR remains at "0". When the internal clock is used, the serial clock and data output is stopped until the next transmit data is written into SIO0BUF (automatic wait). When the subsequent data is written into SIO0BUF, SIO0SR is set to "1", the SCLK0 pin outputs the serial clock, and the transmit operation is restarted. An INTSIO0 interrupt request is generated at the restart of the transmit operation.
(2)
When an external clock is used and SIO0SR is "0" When the data transmission is completed, the SO pin keeps last output value. When an external serial clock is input to the SCLK0 pin after completion of the data transmission, an undefined value is transmitted and the transmit underrun error flag SIO0SR is set to "1". If a transmit underrun error occurs, data must not be written to SIO0BUF during the transmission of an undefined value. (It is recommended to finish the transmit operation by setting SIO0CR to "0" or force the transmit operation to stop by setting SIO0CR to "00".) The transmit underrun error flag SIO0SR is cleared by reading SIO0SR.
(3)
When an internal or external clock is used and SIO0SR is "1" When the data transmission is completed, SIO0SR is cleared to "0". The data in SIO0BUF is transferred to the shift register and the transmission of subsequent data is started. At this time, SIO0SR is set to "1" and an INTSIO0 interrupt request is generated.
17.5.1.5 Stopping the transmit operation
Set SIO0CR to "0" to stop the transmit operation. When SIO0SR is "0", or when the shift operation is not in progress, the transmit operation is stopped immediately and an INTSIO0 interrupt request is generated. When SIO0SR is "1", the transmit operation is stopped after all the data in the shift register is transmitted (reserved stop). At this time, an INTSIO0 interrupt request is generated again. When the transmit operation is completed, SIO0SR are cleared to "0". Other SIO0SR registers keep their values. If the internal clock has been used, the SO0 pin automatically returns to the "H" level. If an external clock has been used, the SO0 pin keeps the last output value. To return the SO0 pin to the "H" level, write "00" to SIO0CR when the operation is stopped. The transmit operation can be forced to stop by setting SIO0CR to "00" during the operation. By setting SIO0CR to "00", SIO0CR and SIO0SR are cleared to "0" and the SIO stops the operation, regardless of the SIO0SR value. The SO0 pin becomes the "H" level. If the internal clock is selected, the SCLK0 pin returns to the initial level.
RA001
Page 246
TMP89FM42
Start operation
Reserved stop
SIO0CR SIO0CR
01
SIO0SR SIO0SR SIO0SR Internal clock
Data A Data B
Automatic wait
Data C Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7
SO0 pin (output) SCLK0 pin (output) INTSIO0 interrupt request SIO0BUF Write to SIO0BUF
Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7
The level is held for the period of the internal clockx(1/2)
An interrupt is generated after transmission in case of reserved stop
A
B
C
Writing data A
Writing data B
Writing data C
Figure 17-3 8-bit Transmit Mode (Internal Clock and Reserved Stop)
Start operation
Forced stop
Start operation
Reserved stop
Forced stop
SIO0CR SIO0CR
01 00 01 00
SIO0SR SIO0SR SIO0SR Internal clock
Data A Data B Data is not held but becomes the H level Clock output is stopped Data C Bit0 Bit1 Bit2 Bit3 Bit4 Bit5
SO0 pin (output) SCLK0 pin (output) INTSIO0 interrupt request SIO0BUF Write to SIO0BUF
Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 Bit0 Bit1 Bit2
Forced stop has priority over reserved stop
A
B
C
D
Writing data A
Writing data B
Writing data C
Writing data D
Figure 17-4 8-bit Transmit Mode (Internal Clock and Forced Stop)
RA001
Page 247
17. Synchronous Serial Interface (SIO)
17.5 Transfer Modes TMP89FM42
Start operation
Reserved stop
SIO0CR SIO0CR
01 00
SIO0SR SIO0SR SIO0SR
Data A Data B Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 Stopped while keeping the current level in the operation with an external clock Data C Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7
SO0 pin (output) SCLK0 pin (input) INTSIO0 interrupt request SIO0BUF Write to SIO0BUF
Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 Bit0 Bit1
An interrupt is generated after transmission in case of reserved stop
A
B
C
Returned to the H level by setting SIOCR1 to "00"
Writing data A
Writing data B
Writing data C
Figure 17-5 8-bit Transmit Mode (External Clock and Reserved Stop)
Start operation
Reserved stop
Start operation
Reserved stop
Forced stop
SIO0CR SIO0CR
01 00 01 00
SIO0SR SIO0SR SIO0SR
Data A Data C Data is not held but becomes the H level Data C Bit0 Bit1 Bit2 Bit3 Bit4 Bit5
SO0 pin (output) SCLK0 pin (input) INTSIO0 interrupt request SIO0BUF Write to SIO0BUF
Writing data A
Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 Bit0 Bit1 Bit2
Forced stop has priority over reserved stop
A
B
C
If two pieces of data are written, the latter data is effective
D
When the operation is restarted after a forced stop, the last data written to the buffer is transmitted. Writing data D
Writing data B
Writing data C
Figure 17-6 8-bit Transmit Mode (External Clock and Forced Stop)
RA001
Page 248
TMP89FM42
Start operation
Reserved stop
SIO0CR SIO0CR
01 00
SIO0SR SIO0SR SIO0SR SIO0SR
Data A Data A Data B Bit7 Data B Data C Bit7 Stopped while keeping the current level in the operation with an external clock
SO0 pin (output) SCLK0 pin (input) INTSIO0 interrupt request SIO0BUF Write to SIO0BUF
Writing data A
Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 Bit0 Bit1
Bit2 Bit3 Bit4 Bit5 Bit6
Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6
Transferred to the buffer immediately after writing
Transferred to the buffer immediately after writing
A
B
C
Returned to the H level by setting SIOCR1 to "00"
Writing data B Reading SIO0SR
Writing data C
Read SIO0SR
Figure 17-7 8-bit Transmit Mode (External Clock and Occurrence of Transmit Underrun Error)
RA001
Page 249
17. Synchronous Serial Interface (SIO)
17.5 Transfer Modes TMP89FM42
17.5.2 8-bit Receive Mode
The 8-bit receive mode is selected by setting SIO0CR to "10".
17.5.2.1 Setting
As in the case of the transmit mode, before starting the receive operation, select the transfer edges at SIO0CR, a transfer format at SIO0CR and a serial clock at SIO0CR. To use the internal clock as the serial clock, select an appropriate serial clock at SIO0CR. To use an external clock as the serial clock, set SIO0CR to "111". The 8-bit receive mode is selected by setting SIO0CR to "10". Reception is started by setting SIO0CR to "1". Writing data to SIO0CR is invalid when the serial communication is in progress, or when SIO0SR is "1". Make these settings while the serial communication is stopped. While the serial communication is in progress (SIO0SR="1"), only writing "00" to SIO0CR or writing "0" to SIO0CR is valid.
17.5.2.2 Starting the receive operation
Reception is started by setting SIO0CR to "1". External serial data is taken into the shift register from the SI0 pin according to the settings of SIO0CR. In the internal clock operation, the serial clock of the selected baud rate is output from the SCLK0 pin. In the external clock operation, an external clock must be supplied to the SCLK0 pin. By setting SIO0CR to "1", SIO0SR are automatically set to "1".
17.5.2.3 Operation on completion of reception
When the data reception is completed, the data is transferred from the shift register to SIO0BUF and an INTSIO0 interrupt request is generated. The receive completion flag SIO0SR is set to "1". In the operation with the internal clock, the serial clock output is stopped until the receive data is read from SIO0BUF (automatic wait). At this time, SIO0SR is set to "0". By reading the receive data from SIO0BUF, SIO0SR is set to "1", the serial clock output is restarted and the receive operation continues. In the operation with an external clock, data can be continuously received without reading the received data from SIO0BUF. In this case, data must be read from SIO0BUF before the subsequent data has been fully received. If the subsequent data is received completely before reading data from SIO0BUF, the overrun error flag SIO0SR is set to "1". When an overrun error has occurred, set SIO0CR to "00" to abort the receive operation. The data received at the occurrence of an overrun error is discarded, and SIO0BUF holds the data value received before the occurrence of the overrun error. SIO0SR is cleared to "0" by reading data from SIO0BUF. SIO0SR is cleared by reading SIO0SR.
17.5.2.4 Stopping the receive operation
Set SIO0CR to "0" to stop the receive operation. When SIO0SR is "0", or when the shift operation is not in progress, the operation is stopped immediately. Unlike the transmit mode, no INTSIO0 interrupt request is generated in this state. When SIO0SR is "1", the operation is stopped after the 8-bit data has been completely received (reserved stop). At this time, an INTSIO0 interrupt request is generated. RA001 Page 250
TMP89FM42
After the operation has stopped completely, SIO0SR are cleared to "0". Other SIO0SR registers keep their values. The receive operation can be forced to stop by setting SIO0CR to "00" during the operation. By setting SIO0CR to "00", SIO0CR and SIO0SR are cleared to "0" and the SIO stops the operation, regardless of the SIO0SR value. If the internal clock is selected, the SCLK0 pin returns to the initial level.
Reserved stop
SIO0CR SIO0CR
10
SIO0SR
Automatic wait
SIO0SR SIO0SR Internal clock
Data A Data C Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7
SI0 pin (input) SCLK0 pin (output) INTSIO0 interrupt request SIO0BUF Read SIO0BUF
Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7
A
C
Reading data A
Reading data C
Figure 17-8 8-bit Receive Mode (Internal Clock and Reserved Stop)
RA001
Page 251
17. Synchronous Serial Interface (SIO)
17.5 Transfer Modes TMP89FM42
Start operation
Forced stop
Start operation Reserved stop Forced stop
SIO0CR SIO0CR
10 00 10 00
SIO0SR SIO0SR SIO0SR Internal clock
Data A
Automatic wait
Data B Bit0 Bit1 Bit2
Data C Bit0 Bit1 Bit2 Bit3
SI0 pin (input) SCLK0 pin (output)
Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7
Returned to the initial level
Returned to the initial level
INTSIO0 interrupt request SIO0BUF Read SIO0BUF
Reading data A
A
Figure 17-9 8-bit Receive Mode (Internal Clock and Forced Stop)
Start operation
Reserved stop
SIO0CR SIO0CR
10
SIO0SR SIO0SR SIO0SR
Data A Data B Data C
SI0 pin (input) SCLK0 pin (input) INTSIO0 interrupt request SIO0BUF Read SIO0BUF
Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7
A
B
C
Reading data A
Reading data B
Figure 17-10 8-bit Receive Mode (External Clock and Reserved Stop)
RA001
Page 252
TMP89FM42
Start operation
Forced stop
Start operation
SIO0CR SIO0CR
10 00 10
SIO0SR SIO0SR SIO0SR
Data A Data B Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 Data C Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7
SI0 pin (input) SCLK0 pin (input)
Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7
Data B is discarded
INTSIO0 interrupt request SIO0BUF Read SIO0BUF
Reading data A Reading data C
A
C
Figure 17-11 8-bit Receive Mode (External Clock and Forced Stop)
Start operation
Forced stop
SIO0CR SIO0CR
10 00
SIO0SR SIO0SR SIO0SR SIO0SR
Data A Data B Data C Subsequent data is received completely before reading data A
SI0 pin (input) SCLK0 pin (input) INTSIO0 interrupt request SIO0BUF Read SIO0BUF
Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7
Data B is discarded
Data C is discarded
A
Reading data A
Read SIO0SR
Reading SUI0SR
Figure 17-12 8-bit Receive Mode (External Clock and Occurrence of Overrun Error)
RA001
Page 253
17. Synchronous Serial Interface (SIO)
17.5 Transfer Modes TMP89FM42
17.5.3 8-bit transmit/receive mode
The 8-bit transmit/receive mode is selected by setting SIO0CR to "11".
17.5.3.1 Setting
Before starting the transmit/receive operation, select the transfer edges at SIO0CR, a transfer format at SIO0CR and a serial clock at SIO0CR. To use the internal clock as the serial clock, select an appropriate serial clock at SIO0CR. To use an external clock as the serial clock, set SIO0CR to "111". The 8-bit transmit/receive mode is selected by setting SIO0CR to "11". The transmit/receive operation is started by writing the first byte of transmit data to SIO0BUF and then setting SIO0CR to "1". Writing data to SIO0CR is invalid when the serial communication is in progress, or when SIO0SR is "1". Make these settings while the serial communication is stopped. While the serial communication is in progress (SIO0SR="1"), only writing "00" to SIO0CR or writing "0" to SIOCR is valid.
17.5.3.2 Starting the transmit/receive operation
The transmit/receive operation is started by writing data to SIO0BUF and then setting SIO0CR to "1". The transmit data is transferred from SIO0BUF to the shift register, and the serial data is transmitted from the SO0 pin according to the settings of SIO0CR. At the same time, the serial data is received from the SI0 pin according to the settings of SIO0CR. In the internal clock operation, the serial clock of the selected baud rate is output from the SCLK0 pin. In the external clock operation, an external clock must be supplied to the SCLK0 pin. The transmit data becomes undefined if the transmit/receive operation is started without writing any transmit data to SIO0BUF. By setting SIO0CR to "1", SIO0SR are automatically set to "1" and an INTSIO0 interrupt request is generated. SIO0SR is cleared to "0" when the 8th bit of data is received.
17.5.3.3 Transmit buffer and shift operation
If any data is written to SIO0BUF when the serial communication is in progress and the shift register is empty, the written data is transferred to the shift register immediately. At this time, SIO0SR remains at "0". If any data is written to SIO0BUF when some data remains in the shift register, SIO0SR is set to "1". If new data is written to SIO0BUF in this state, the contents of SIO0BUF are overwritten by the new value. Make sure that SIO0SR is "0" before writing data to SIO0BUF.
17.5.3.4 Operation on completion of transmission/reception
When the data transmission/reception is completed, SIO0SR is set to "1" and an INTSIO0 interrupt request is generated. The operation varies depending on the operating clock.
RA001
Page 254
TMP89FM42
(1)
When the internal clock is used If SIO0SR is "1", it is cleared to "0" and the transmit/receive operation continues. If SIO0SR is already "1", SIO0SR is set to "1". If SIO0SR is "0", the transmit/receive operation is aborted. The SCLK0 pin becomes the initial state and the SO0 pin becomes the "H" level. SIO0SR remains at "0". When the subsequent data is written to SIO0BUF, SIO0SR is set to "1", the SCLK0 pin outputs the clock and the transmit/receive operation is restarted. To confirm the receive data, read it from SIO0BUF before writing data to SIO0BUF.
(2)
When an external clock is used The transmit/receive operation continues. If the external serial clock is input without writing any data to SIO0BUF, the last data value set to SIO0BUF is re-transmitted. At this time, the transmit underrun error flag SIO0SR is set to "1". When the next 8-bit data is received completely before SIO0BUF is read, or in the state of SIO0SR="1", SIO0SR is set to "1".
17.5.3.5 Stopping the transmit/receive operation
Set SIO0CR to "0" to stop the transmit/receive operation. When SIO0SR is "0", or when the shift operation is not in progress, the operation is stopped immediately. Unlike the transmit mode, no INTSIO0 interrupt request is generated in this state. When SIO0SR is "1", the operation is stopped after the 8-bit data is received completely. At this time, an INTSIO0 interrupt request is generated. After the operation has stopped completely, SIO0SR are cleared to "0". Other SIO0SR registers keep their values. If the internal clock has been used, the SO0 pin automatically returns to the "H" level. If an external clock has been used, the SO0 pin keeps the last output value. To return the SO0 pin to the "H" level, write "00" to SIO0CR when the operation is stopped. The transmit/receive operation can be forced to stop by setting SIO0CR to "00" during the operation. By setting SIO0CR to "00", SIO0CR and SIO0SR are cleared to "0" and the SIO stops the operation, regardless of the SIO0SR value. The SO0 pin becomes the "H" level. If the internal clock is selected, the SCLK0 pin returns to the initial level.
RA001
Page 255
17. Synchronous Serial Interface (SIO)
17.5 Transfer Modes TMP89FM42
Start operation
Reserved stop
SIO0CR
SIO0SR
Wait
SIO0SR SIO0SR SIO0SR Internal clock
Data A Data B Data C Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 Data F Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7
SI0 pin (input)
Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 Data D Data E
SO0 pin (output) SCLK0 pin (output) INTSIO0 interrupt request SIO0BUF (Read buffer) Read SIO0BUF
Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7
A
Reading data A
B
Reading data B
C
Reading data C
SIO0BUF (Write buffer) Write to SIO0BUF
D
E
F
G
Writing data D
Writing data E
Writing data F
Writing data G
Figure 17-13 8-bit Transmit/Receive Mode (Internal Clock and Reserved Stop)
RA001
Page 256
TMP89FM42
Start operation
Reserved stop
SIO0CR SIO0CR
11 00
SIO0SR SIO0SR SIO0SR SIO0SR
Data A Data B Data C Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 Data F Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7
SI0 pin (input)
Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 Data D Data E
SO0 pin (output) SCLK0 pin (input) INTSIO0 interrupt request SIO0BUF (Read buffer) Read SIO0BUF
Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7
A
Reading data A
B
Reading data B
C
Reading data C
SIO0BUF (Write buffer) Write to SIO0BUF
D
E
F
G
Writing data D
Writing data E
Writing data F
Writing data G
Figure 17-14 8-bit Transmit/Receive Mode (External Clock and Reserved Stop)
RA001
Page 257
17. Synchronous Serial Interface (SIO)
17.5 Transfer Modes TMP89FM42
Start operation
Reserved stop
SIO0CR
SIO0SR SIO0SR SIO0SR SIO0SR SIO0SR SIO0SR
Data A Data B Data C
SI0 pin (input)
Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 Data D Data D Data F Data G
SO0 pin (output) SCLK0 pin (input) INTSIO0 interrupt request SIO0BUF (Read buffer) Read SIO0BUF SIO0BUF (Write buffer) Write to SIO0BUF
Writing data D
Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7
A
Reading data A
C
Reading data C
D
F
G
Writing data F
Writing data G
Read SIO0SR
Figure 17-15 8-bit Transmit/Receive Mode (External Clock, Occurrence of Transmit Underrun Error and Occurrence of Overrun Error)
RA001
Page 258
TMP89FM42
17.6 AC Characteristics
tSCY tSCYL SCLK pin VSCLKL tSIS SI pin tSOD tSIH tSCYH VSCLKH
SO pin
Figure 17-16 AC Characteristics
(VSS = 0 V, VDD = 4.5 V - 5.5 V, Topr = -40 to 85C) Parameter SCLK cycle time SCLK "L" pulse width Symbol tSCY tSCYL Internal clock operation SO pin and SCLK pin load capacity=100 pF Condition Min 2 / fcgck 1 / fcgck - 25 1 / fcgck - 15 60 35 -50 2 / fcgck 1 / fcgck External clock operation SO pin and SCLK pin load capacity=100 pF 1 / fcgck 50 50 0 0 VDD x 0.70 50 60 VDD x 0.30 V VDD ns Typ. Max Unit
SCLK "H" pulse width SI input setup time SI input hold time SO output delay time SCLK cycle time SCLK "L" pulse width SCLK "H" pulse width SI input setup time SI input hold time SO output delay time SCLK low-level input voltage SCLK high-level input voltage
tSCYH tSIS tSIH tSOD tSCY tSCYL tSCYH tSIS tSIH tSOD tSCLKL tSCLKH
tBI SCLK0 pin SO0 pin SI0 pin A6 C6 A7 C7 B0 D0 B1 D1 B2 D2 Trailing edge at the Leading edge at the 8th bit (receive edge) 1st bit (transmit edge)
Symbol tBI Name Interval time between bytes Minimum time 4/fcgck
Figure 17-17 Interval time between bytes
RA001
Page 259
17. Synchronous Serial Interface (SIO)
17.7 Revision History TMP89FM42
17.7 Revision History
Rev
Description "Table 17-3 Transfer Baud Rate" Revised table (Add some fcgck condition).
RA001 "17.6 AC Characteristics" Revised table (Add some fcgck condition).
RA001
Page 260
TMP89FM42
18. Serial Bus Interface (SBI)
The TMP89FM42 contains 1 channels of serial bus interface (SBI). The serial bus interface supports serial communication conforming to the I2C bus standards. It has clock synchronization and arbitration functions, and supports the multi-master in which multiple masters are connected on a bus. It also supports the unique free data format.
18.1 Communication Format
18.1.1 I2C bus
The I2C bus is connected to devices via the SDA0 and SCL0 pins and can communicate with multiple devices.
VDD
SDA SCL
Device 1
SDA SCL
Device 2
SDA SCL
Device n
Figure 18-1 Device Connections
Communications are implemented between a master and slave. The master transmits the start condition, the slave addresses, the direction bit and the stop condition to the slave(s) connected to the bus, and transmits and receives data. The slave detects these conditions transmitted from the master by the hardware, and transmits and receives data. The data format of the I2C bus that can communicate via the serial bus interface is shown in Figure 18-2. The serial bus interface does not support the following functions among those specified by the I2C bus standards: 1. Start byte 2. 10-bit addressing 3. SDA and SCL pins falling edge slope control
RA001
Page 261
18. Serial Bus Interface (SBI)
18.1 Communication Format TMP89FM42
(a) Addressing format 8 bits S
Slave address
1 RA /C WK
1 to 8 bits Data
1 A C K
1 to 8 bits Data
1 A CP K
1 (b) Addressing format (with restart) 8 bits S
Slave address
1 or more
1 RA /C WK
1 to 8 bits Data 1 or more
1 A CS K
8 bits
Slave address
1 RA /C WK
1 to 8 bits Data 1 or more
1 A CP K
1
1
S R/W ACK P
: Start condition : Direction bit : Acknowledge bit : Stop condition
Figure 18-2 Data Format of I2C Bus
18.1.2 Free data format
The free data format is for communication between a master and slave. In the free data format, the slave address and the direction bit are processed as data.
(a) Free data format 8 bits S Data 1 S R/W ACK P : Start condition : Direction bit : Acknowledge bit : Stop condition 1 A C K 1 to 8 bits Data 1 A C K 1 or more 1 to 8 bits Data 1 A CP K
Figure 18-3 Free Data Format
RA001
Page 262
TMP89FM42
18.2 Configuration
INTSBI Interrupt request
Transfer control circuit
Software reset circuit
MST/TRX/BB/PIN
Clock control circuit
Shift register
Data control circuit
AL/AAS/AS0 MST/TRX/ BB
Noise canceller
SDA
SWRST
NOACK
ACK
SCK
SBI0CR2
SBI0CR1
I2C0AR
ALS
BC
SA
SBI0DBR
SBI0SR2
Figure 18-4 Serial Bus Interface 0 (SBI0)
RA001
Page 263
LRB
Input/output control
Noise canceller
SCL
18. Serial Bus Interface (SBI)
18.3 Control TMP89FM42
18.3 Control
The following registers are used to control the serial bus interface and monitor the operation status. * Serial bus interface control register 1 (SBI0CR1) * Serial bus interface control register 2 (SBI0CR2) * Serial bus interface status register 2 (SBI0SR2) * Serial bus interface data buffer register (SBI0DBR) * I2C bus address register (I2C0AR) In addition, the serial bus interface has low power consumption registers that save power when the serial bus interface is not being used. Low power consumption register 1
POFFCR1 (0x0F75) Bit Symbol Read/Write After reset 7 R/W 0 6 R/W 0 5 R/W 0 4 SBI0EN R/W 0 3 R/W 0 2 R/W 0 1 UART1EN R/W 0 0 UART0EN R/W 0
SBI0EN
I2C0 control
0 1 0 1 0 1
Disable Enable Disable Enable Disable Enable
UART1EN
UART1 control
UART0EN
UART0 control
Note 1: When SBI0EN is cleared to "0", the clock supply to the serial bus interface is stopped. At this time, the data written to the serial bus interface control registers is invalid. When the serial bus interface is used, set SBI0EN to "1" and then write the data to the serial bus interface control registers.
Serial bus interface control register 1
SBI0CR1 (0x0022) 7 Bit Symbol Read/Write After reset 0 6 BC R/W 0 0 5 4 ACK R/W 0 3 NOACK R/W 0 0 2 1 SCK R/W 0 0 0
RA001
Page 264
TMP89FM42
ACK=0 BC Number of clocks for data transfer 8 1 2 3 4 5 6 7 Master mode Not generating the clocks for an acknowledge signal. Generate an interrupt request when the data transfer is finished (non-acknowledgement mode) Generate the clocks for an acknowledge signal and an interrupt request when the data transfer is finished (acknowledgement mode) Master mode Don't Care Number of data bits 8 1 2 3 4 5 6 7
ACK=1 Number of clocks for data transfer 9 2 3 4 5 6 7 8 Slave mode
Number of data bits
000: 001: BC Number of data bits 010: 011: 100: 101: 110: 111: ACK
8 1 2 3 4 5 6 7
0: ACK Generation and counting of the clocks for an acknowledge signal
Generate an interrupt request when the data transfer is finished (non-acknowledgement mode)
1:
Count the clocks for an acknowledge signal and generate an interrupt request when the data transfer is finished (acknowledgement mode) Slave mode Enable the slave address match detection and the GENERAL CALL detection Disable the slave address match detection and the GENERAL CALL detection fscl@fcgck= 8MHz 381KHz 320KHz 242KHz 163KHz 99KHz 55KHz 29KHz 15KHz fscl@fcgck= 4MHz Reserved (Note5) Reserved (Note5) Reserved (Note5) 82KHz 49KHz 28KHz 15KHz 8KHz
NOACK Enables/disables the slave address match detection and the GENERAL CALL detection 0:
NOACK
1:
Don't Care tHIGH(m/fcgck) m tLOW(n/fcgck) n 12 14 18 26 42 74 138 266
SCK 000: HIGH and LOW periods of the serial clock in the master mode Time before the release of the SCL pin in the slave mode 001: 010: 011: 100: 101: 110: 111:
9 11 15 23 39 71 135 263
SCK
Note 1: fcgck: Gear clock [Hz], fs: Low-frequency clock oscillation circuit clock Note 2: Don't change the contents of the registers when the start condition is generated, the stop condition is generated or the data transfer is in progress. Write data to the registers before the start condition is generated or during the period from when an interrupt request is generated for stopping the data transfer until it is released. Note 3: After a software reset is generated, all the bits of SBI0CR2 register except SBI0CR2 and the SBI0CR1, I2C0AR and SBI0SR2 registers are initialized. Note 4: When the operation is switched to STOP, IDLE0 or SLOW mode, the SBI0CR2 register, except SBI0CR2, and the SBI0CR1, I2C0AR and SBI0DBR registers are initialized. Note 5: When fcgck is 4MHz, SCK should be not set to 0y000, 0y001 or 0y010 because it is not possible to satisfy the bus specification of fast mode.
Serial bus interface control register 2
SBI0CR2 (0x0023) 7 Bit Symbol Read/Write After reset MST W 0 6 TRX W 0 5 BB W 0 4 PIN W 1 3 SBIM W 0 2 R 0 1 SWRST W 0 0
RA001
Page 265
18. Serial Bus Interface (SBI)
18.3 Control TMP89FM42
0: Slave MST Master/slave selection 1: Master 0: Receiver TRX Transmitter/receiver selection 1: Transmitter 0: Generate the stop condition (when MST, TRX and PIN are "1") BB Start/stop generation 1: Generate the start condition (when MST, TRX and PIN are "1") 0: - (Cannot clear this bit by the software) PIN Cancel interrupt service request 1: Cancel interrupt service request SBIM SWRST Serial bus interface operation mode register Software reset start bit 0: Port mode 1: Serial bus interface mode The software reset starts by first writing "10" and next writing "01"
Note 1: When SBI0CR2 is "0", no value can be written to SBI0CR2 except SBI0CR2. Before writing values to SBI0CR2, write "1" to SBI0CR2 to activate the serial bus interface mode. Note 2: Don't change the contents of the registers, except SBI0CR2, when the start condition is generated, the stop condition is generated or the data transfer is in progress. Write data to the registers before the start condition is generated or during the period from when an interrupt request is generated for stopping the data transfer until it is released. Note 3: Make sure that the port is in a high state before switching the port mode to the serial bus interface mode. Make sure that the bus is free before switching the serial bus interface mode to the port mode. Note 4: SBI0CR2 is a write-only register, and must not be accessed by using a read-modify-write instruction, such as a bit operation. Note 5: After a software reset is generated, all the bits of SBI0CR2 register except SBI0CR2 and the SBI0CR1, I2C0AR and SBI0SR2 registers are initialized. Note 6: When the operation is switched to STOP, IDLE0 or SLOW mode, the SBI0CR2 register, except SBI0CR2, and the SBI0CR1, I2C0AR and SBI0DBR registers are initialized.
Serial bus interface status register 2
SBI0SR2 (0x0023) 7 Bit Symbol Read/Write After reset MST R 0 6 TRX R 0 5 BB R 0 4 PIN R 1 3 AL R 0 2 AAS R 0 1 AD0 R 0 0 LRB R *
MST
Master/slave selection status monitor Transmitter/receiver selection status monitor Bus status monitor
0: Slave 1: Master 0: Receiver 1: Transmitter 0: Bus free
TRX
BB
1: Bus busy PIN Interrupt service requests status monitor Arbitration lost detection monitor 1: Arbitration lost detected AAS Slave address match detection monitor "GENERAL CALL" detection monitor Last received bit monitor 1: Last received bit is "1" 0: 1: Detect slave address match or "GENERAL CALL" 0: 1: Detect "GENERAL CALL" 0: Last received bit is "0" LRB 0: Requesting interrupt service 1: Releasing interrupt service request 0: AL
AD0
Note 1: * : Unstable Note 2: When SBI0CR2 becomes "0", SBI0SR is initialized. Note 3: After a software reset is generated, all the bits of the SBI0CR2 register except SBI0CR2 and the SBI0CR1, I2C0AR and SBI0SR2 registers are initialized. Note 4: When the operation is switched to STOP, IDLE0 or SLOW mode, the SBI0CR2 register, except SBI0CR2, and the SBI0CR1, I2C0AR and SBI0DBR registers are initialized.
RA001
Page 266
TMP89FM42
I2C bus address register
I2C0AR (0x0024) 7 Bit Symbol Read/Write After reset R/W 0 R/W 0 R/W 0 6 5 4 SA0 R/W 0 R/W 0 R/W 0 R/W 0 3 2 1 0 ALS R/W 0
SA ALS
Slave address setting
2
Slave address in the slave mode 0: I C bus mode 1: Free data format
Communication format selection
Note 1: Don't set I2C0AR to "0x00". If it is set to "0x00", the slave address is deemed to be matched when the I2C bus standard start byte ("0x01") is received in the slave mode. Note 2: Don't change the contents of the registers when the start condition is generated, the stop condition is generated or the data transfer is in progress. Write data to the registers before the start condition is generated or during the period from when an interrupt request is generated for stopping the data transfer until it is released. Note 3: After a software reset is generated, all the bits of the SBI0CR2 register except SBI0CR2 and the SBI0CR1, I2C0AR and SBI0SR2 registers are initialized. Note 4: When the operation is switched to STOP, IDLE0 or SLOW mode, the SBI0CR2 register, except SBI0CR2, and the SBI0CR1, I2C0AR and SBI0DBR registers are initialized.
Serial bus interface data buffer register
SBI0DBR (0x0025) 7 Bit Symbol Read/Write After reset 0 0 0 0 6 5 4 SBI0DBR R/W 0 0 0 0 3 2 1 0
Note 1: Write the transmit data beginning with the most significant bit (bit 7). Note 2: SBI0DBR has individual writing and reading buffers, and written data cannot be read out. Therefore, SBI0DBR must not be accessed by using a read-modify-write instruction, such as a bit operation. Note 3: Don't change the contents of the registers when the start condition is generated, the stop condition is generated or the data transfer is in progress. Write data to the registers before the start condition is generated or during the period from when an interrupt request is generated for stopping the data transfer until it is released. Note 4: To set SBI0CR2 to "1" by writing the dummy data to SBI0DBR, write 0x00. Writing any data other than 0x00 causes an improper value in the subsequently received data. Note 5: When the operation is switched to STOP, IDLE0 or SLOW mode, the SBI0CR2 register, except SBI0CR2, and the SBI0CR1, I2C0AR and SBI0DBR registers are initialized.
18.4 Functions
18.4.1 Low Power Consumption Function
The serial bus interface has a low power consumption register (POFFCR1) that saves power when the serial bus interface is not being used. Setting POFFCR1 to "0" disables the basic clock supply to the serial bus interface to save power. Note that this makes the serial bus interface unusable. Setting POFFCR1 to "1" enables the basic clock supply to the serial bus interface and makes external interrupts usable. After reset, POFFCR1 is initialized to "0", and this makes the serial bus interface unusable. When using the serial bus interface for the first time, be sure to set POFFCR1 to "1" in the initial setting of the program (before the serial bus interface control registers are operated). Do not change POFFCR1 to "0" during the serial bus interface operation, otherwise serial bus interface may operate unexpectedly.
RA001
Page 267
18. Serial Bus Interface (SBI)
18.4 Functions TMP89FM42
18.4.2 Selecting the slave address match detection and the GENERAL CALL detection
SBI0CR1 enables and disables the slave address match detection and the GENERAL CALL detection in the slave mode. Clearing SBI0CR1 to "0" enables the slave address match detection and the GENERAL CALL detection. Setting SBI0CR1 to "1" disables the subsequent slave address match and GENERAL CALL detections. The slave addresses and "GENERAL CALL" sent from the master are ignored. No acknowledgement is returned and no interrupt request is generated. In the master mode, SBI0CR1 is ignored and has no influence on the operation.
Note:If SBI0CR1 is cleared to "0" during data transfer in the slave mode, it remains at "1" and returns an acknowledge signal of data transfer.
18.4.3 Selecting the number of clocks for data transfer and selecting the acknowledgement or non-acknowledgment mode
1-word data transfer consists of data and an acknowledge signal. When the data transfer is finished, an interrupt request is generated. SBI0CR1 is used to select the number of bits of data to be transmitted/received subsequently. The acknowledgment mode is activated by setting SBI0CR1 to "1". The master device generates the clocks for an acknowledge signal and outputs an acknowledge signal in the receiver mode. The slave device counts the clocks for an acknowledge signal and outputs an acknowledge signal in the receiver mode. The non-acknowledgment mode is activated by setting SBI0CR1 to "0". The master device does not generate the clocks for an acknowledge signal. The slave device does not count the clocks for an acknowledge signal.
18.4.3.1 Number of clocks for data transfer
The number of clocks for data transfer is set by using SBI0CR1 and SBI0CR1. The acknowledgment mode is activated by setting SBI0CR1 to "1". In the acknowledgment mode, the master device generates the clocks that correspond to the number of data bits, generates the clocks for an acknowledge signal, and generates an interrupt request. The slave device counts the clocks that correspond to the data bits, counts the clocks for an acknowledge signal, and generates an interrupt request. The non-acknowledgment mode is activated by setting SBI0CR1 to "0". In the non-acknowledgment mode, the master device generates the clocks that correspond to the number of data bits, and generates an interrupt request. The slave device counts the clocks that correspond to the data bits, and generates an interrupt request.
RA001
Page 268
TMP89FM42
SBI0CR1="110", SBI0CR1="0"
SBI0CR1="011", SBI0CR1="1"
1
2
3
4
5
6
1
2
3
4
Figure 18-5 Number of Clocks for Data Transfer and SBI0CR1 and SBI0CR1
The relationship between the number of clocks for data transfer and SBI0CR1 and SBI0CR1 is shown in Table 18-1. Table 18-1 Relationship between the Number of Clocks for Data Transfer and SBI0CR1 and SBI0CR1
ACK=0 (Non-acknowledgment mode) BC Number of clocks for data transfer 8 1 2 3 4 5 6 7 Number of data bits 8 1 2 3 4 5 6 7 ACK=1 (Acknowledgment mode) Number of clocks for data transfer 9 2 3 4 5 6 7 8 Number of data bits 8 1 2 3 4 5 6 7
000 001 010 011 100 101 110 111
BC is cleared to "000" by the start condition. Therefore, the slave address and the direction bit are always transferred in 8-bit units. In other cases, BC keeps the set value.
Note: SBI0CR1 must be set before transmitting or receiving a slave address. When SBI0CR1 is cleared, the slave address match detection and the direction bit detection are not executed properly.
18.4.3.2 Output of an acknowledge signal
In the acknowledgment mode, the SDA0 pin changes as follows during the period of the clocks for an acknowledge signal. * In the master mode In the transmitter mode, the SDA0 pin is released to receive an acknowledge signal from the receiver during the period of the clocks for an acknowledge signal. In the receiver mode, the SDA0 pin is pulled down to the low level and an acknowledge signal is generated during the period of the clocks for an acknowledge signal. * In the slave mode When a match between the received slave address and the slave address set to I2C0AR is detected or when a GENERAL CALL is received, the SDA0 pin is pulled down to the low level and an acknowledge signal is generated during the period of the clocks for an acknowledge signal.
RA001
Page 269
18. Serial Bus Interface (SBI)
18.4 Functions TMP89FM42
During the data transfer after the slave address match is detected or a "GENERAL CALL" is received in the transmitter mode, the SDA0 pin is released to receive an acknowledge signal from the receiver during the period of the clocks for an acknowledge signal. In the receiver mode, the SDA0 pin is pulled down to the low level and an acknowledge signal is generated. Table 18-2 shows the states of the SCL0 and SDA0 pins in the acknowledgment mode.
Note: In the non-acknowledgment mode, the clocks for an acknowledge signal are not generated or counted, and thus no acknowledge signal is output.
Table 18-2 States of the SCL0 and SDA0 Pins in the Acknowledgment Mode
Mode Pin SCL0 Master SDA0 Release the pin to receive an acknowledge signal Count the clocks for an acknowledge signal Output the low level as an acknowledge signal to the pin Count the clocks for an acknowledge signal Condition Transmitter Add the clocks for an acknowledge signal. Receiver Add the clocks for an acknowledge signal
SCL0
When the slave address match is detected or a "GENERAL CALL" is received
-
Slave SDA0
Output the low level as an acknowledge signal to the pin
During transfer after the slave address match is detected or a "GENERAL CALL" is received
Release the pin to receive an acknowledge signal
Output the low level as an acknowledge signal to the pin
18.4.4 Serial clock
18.4.4.1 Clock source
SBI0CR1 is used to set the HIGH and LOW periods of the serial clock to be output in the master mode.
SCK 000: 001: 010: 011: 100: 101: 110: 111:
tHIGH(m/fcgck) m 9 11 15 23 39 71 135 263
tLOW(n/fcgck) n 12 14 18 26 42 74 138 266
RA001
Page 270
TMP89FM42
SCL output
tHIGH tLOW 1/fscl
t HIGH = m / fcgck tLOW = n / fcgck fscl = 1/(t HIGH + tLOW )
Figure 18-6 SCL Output
Note: There are cases where the HIGH period differs from tHIGH selected at SBI0CR1 when the rising edge of the SCL pin becomes blunt due to the load capacity of the bus.
In the master mode, the hold time when the start condition is generated is tHIGH [s] and the setup time when the stop condition is generated is tHIGH [s]. When SBI0CR2 is set to "1" in the slave mode, the time that elapses before the release of the SCL pin is tLOW [s]. In both the master and slave modes, the high level period must be 3/fcgck[s] or longer and the low level period must be 5/fcgck[s] or longer for the externally input clock, regardless of the SBI0CR1 setting.
SCL input
tHIGH tLOW
t HIGH >= tLOW >=
Figure 18-7 SCL Input
18.4.4.2 Clock synchronization
In the I2C bus, due to the structure of the pin, in order to drive a bus with a wired AND, a master device which pulls down a clock pulse to low will, in the first place, invalidate the clock pulse of another master device which generates a high-level clock pulse. Therefore, the master outputting the high level must detect this to correspond to it. The serial bus interface circuit has a clock synchronization function. This function ensures normal transfer even if there are two or more masters on the same bus. The example explains clock synchronization procedures when two masters simultaneously exist on a bus.
RA001
Page 271
18. Serial Bus Interface (SBI)
18.4 Functions TMP89FM42
SCL pin (Master 1)
Wait
Count start
SCL pin (Master 2)
Count reset
Count reset
SCL (Bus) a b c
Figure 18-8 Example of Clock Synchronization
As Master 1 pulls down the SCL pin to the low level at point "a", the SCL line of the bus becomes the low level. After detecting this situation, Master 2 resets counting a clock pulse in the high level and sets the SCL pin to the low level. Master 1 finishes counting a clock pulse in the low level at point "b" and sets the SCL pin to the high level. Since Master 2 holds the SCL line of the bus at the low level, Master 1 waits for counting a clock pulse in the high level. After Master 2 sets a clock pulse to the high level at point "c" and detects the SCL line of the bus at the high level, Master 1 starts counting a clock pulse in the high level. Then, the master, which has finished the counting a clock pulse in the high level, pulls down the SCL pin to the low level. The clock pulse on the bus is determined by the master device with the shortest high-level period and the master device with the longest low-level period from among those master devices connected to the bus.
18.4.5 Master/slave selection
To set a master device, SBI0CR2 should be set to "1". To set a slave device, SBI0CR2 should be cleared to "0". When a stop condition on the bus or an arbitration lost is detected, SBI0CR2 is cleared to "0" by the hardware.
18.4.6 Transmitter/receiver selection
To set the device as a transmitter, SBI0CR2 should be set to "1". To set the device as a receiver, SBI0CR2 should be cleared to "0". For the I2C bus data transfer in the slave mode, SBI0CR2 is set to "1" by the hardware if the direction bit (R/W) sent from the master device is "1", and is cleared to "0" if the bit is "0". In the master mode, after an acknowledge signal is returned from the slave device, SBI0CR2 is cleared to "0" by hardware if a transmitted direction bit is "1", and is set to "1" by hardware if it is "0". When an acknowledge signal is not returned, the current condition is maintained. When a stop condition on the bus or an arbitration lost is detected, SBI0CR2 is cleared to "0" by the hardware. Table 18-3 shows SBI0CR2 changing conditions in each mode and SBI0CR2 value after changing.
Note:When SBI0CR1 is "1", the slave address match detection and the GENERAL CALL detection are disabled, and thus SBI0CR2 remains unchanged.
RA001
Page 272
TMP89FM42
Table 18-3 SBI0CR1 Operation in Each Mode
Mode Direction bit "0" Slave mode "1" Master mode "0" ACK signal is returned "1" "0" Changing condition A received slave address is the same as the value set to I2C0AR TRX after changing "0" "1" "1"
When the serial bus interface circuit operates in the free data format, a slave address and a direction bit are not recognized. They are handled as data just after generating the start condition. SBI0CR2 is not changed by the hardware.
18.4.7 Start/stop condition generation
When SBI0SR2 is "0", a slave address and a direction bit which are set to the SBI0DBR are output on a bus after generating a start condition by writing "1" to SBI0CR2 , SBI0CR2, SBI0CR2 and SBI0CR2. It is necessary to set SBI0CR1 to "1" before generating the start condition.
SCL0 pin
1
2
3
4
5
6
7
8
9
SDA0 pin
Start condition
A6
A5
A4
A3
A2
A1
A0
R/W
Acknowledge signal
Slave address and direction bit
INTSBI0 Interrupt request
Figure 18-9 Generating the Start Condition and a Slave Address
When SBI0CR2 is "1", the sequence of generating the stop condition on the bus is started by writing "1" to SBI0CR2, SBI0CR2 and SBI0CR2 and writing "0" to SBI0CR2. When a stop condition is generated. The SCL line on a bus is pulled down to the low level by another device, a stop condition is generated after releasing the SCL line.
SCL0 pin
SDA0 pin
Stop condition
Figure 18-10 Stop Condition Generation
The bus condition can be indicated by reading the contents of SBI0SR2. SBI0SR2 is set to "1" when the start condition on the bus is detected (Bus Busy State) and is cleared to "0" when the stop condition is detected (Bus Free State).
RA001
Page 273
18. Serial Bus Interface (SBI)
18.4 Functions TMP89FM42
18.4.8 Interrupt service request and release
When a serial bus interface circuit is in the master mode and transferring a number of clocks set by SBI0CR1 and SBI0CR1 is complete, a serial bus interface interrupt request (INTSBI0) is generated. In the slave mode, a serial bus interface interrupt request (INTSBI0) is generated when the above and following conditions are satisfied: * At the end of the acknowledge signal when the received slave address matches to the value set by the I2C0AR with SBI0CR1 set at "0" * At the end of the acknowledge signal when a "GENERAL CALL" is received with SBI0CR1 set at "0" * At the end of transferring or receiving after matching of the slave address or receiving of "GENERAL CALL" When a serial bus interface interrupt request occurs, SBI0CR2 is cleared to "0". During the time that SBI0CR2 is "0", the SCL0 pin is pulled down to the low level.
t LOW
SCL0 pin is pulled to low when SBI0CR2 is "0"
SCL0 pin
1
2
3
7
8
9
1
INTSBI0 interrupt request
SBI0CR2
Set SBI0CR2 to "1" or write data to SBI0DBR
Figure 18-11 SBI0CR2 and SCL0 Pin
Writing data to SBI0DBR sets SBI0CR2 to "1". The time from SBI0CR2 being set to "1" until the SBI0 pin is released takes tLOW. Although SBI0CR2 can be set to "1" by the software, SBI0CR2 can not be cleared to "0" by the software.
18.4.9 Setting of serial bus interface mode
SBI0CR2 is used to set serial bus interface mode. Setting SBI0CR2 to "1" selects the serial bus interface mode. Setting it to "0" selects the port mode. Set SBI0CR2 to "1" in order to set serial bus interface mode. Before setting of serial bus interface mode, confirm serial bus interface pins in a high level, and then, write "1" to SBI0CR2. And switch a port mode after confirming that a bus is free and set SBI0CR2 to "0".
Note:When SBI0CR2 is "0", no data can be written to SBI0CR2 except SBI0CR2. Before setting values to SBI0CR2, write "1" to SBI0CR2 to activate the serial bus interface mode.
18.4.10Software reset
The serial bus interface circuit has a software reset function that initializes the serial bus interface circuit. If the serial bus interface circuit locks up, for example, due to noise, it can be initialized by using this function. RA001 Page 274
TMP89FM42
A software reset is generated by writing "10" and then "01" to SBI0CR2. After a software reset is generated, the serial bus interface circuit is initialized and all the bits of SBI0CR2 register, except SBI0CR2 and the SBI0CR1, I2C0AR and SBI0SR2 registers, are initialized.
18.4.11Arbitration lost detection monitor
Since more than one master device can exist simultaneously on a bus, a bus arbitration procedure is implemented in order to guarantee the contents of transferred data. Data on the SDA line is used for bus arbitration of the I2C bus. The following shows an example of a bus arbitration procedure when two master devices exist simultaneously on a bus. Master 1 and Master 2 output the same data until point "a". After that, when Master 1 outputs "1" and Master 2 outputs "0", since the SDA line of a bus is wired AND, the SDA line is pulled down to the low level by Master 2. When the SCL line of a bus is pulled-up at point "b", the slave device reads data on the SDA line, that is data in Master 2. Data transmitted from Master 1 becomes invalid. The state in Master 1 is called "arbitration lost". A master device which loses arbitration releases the SDA pin and the SCL pin in order not to effect data transmitted from other masters with arbitration. When more than one master sends the same data at the first word, arbitration occurs continuously after the second word.
SCL (Bus)
SDA pin (Master 1) The SDA pin becomes "1" after losing arbitration.
SDA pin (Master 2)
SDA (Bus) a b
Figure 18-12 Arbitration Lost
The serial bus interface circuit compares levels of a SDA line of a bus with its SDA pin at the rising edge of the SCL line. If the levels are unmatched, arbitration is lost and SBI0SR2 is set to "1". When SBI0SR2 is set to "1", SBI0CR2 and SBI0CR2 are cleared to "0" and the mode is switched to a slave receiver mode. Thus, the serial bus interface circuit stops output of clock pulses during data transfer after the SBI0SR2 is set to "1". After the data transfer is completed, SBICR2 is cleared to "0" and the SCL pin is pulled down to the low level. SBI0SR2 is cleared to "0" by writing data to the SBI0DBR, reading data from the SBI0DBR or writing data to the SBI0CR2.
RA001
Page 275
18. Serial Bus Interface (SBI)
18.4 Functions TMP89FM42
SCL pin Master A SDA pin
1
2
3
4
5
6
7
8
9
1
2
3
D7A D6A D5A D4A D3A D2A D1A D0A
D7A' D6A' D5A'
SCL pin Master B SDA pin
1
2
3
4
5
6
7
8
9
Stop clock output D7A D6A Releasing SDA pin and SCL pin to high level as losing arbitration.
SBI0SR2 SBI0CR2
SBI0CR2 Access to SBI0DBR or SBI0CR2 INTSBI0 Interrupt request
Figure 18-13 Example When Master B is a Serial Bus Interface Circuit
18.4.12Slave address match detection monitor
In the slave mode, SBI0SR2 is set to "1" when the received data is "GENERAL CALL" or the received data matches the slave address setting by I2C0AR with SBI0CR1 set at "0" and the I2C bus mode is active (I2C0AR="0"). Setting SBI0CR1 to "1" disables the subsequent slave address match and GENERAL CALL detections. SBI0SR2 remains at "0" even if a "GENERAL CALL" is received or the same slave address as the I2C0AR set value is received. When a serial bus interface circuit operates in the free data format (I2C0AR= "1"), SBI0SR2 is set to "1" after receiving the first 1-word of data. SBI0SR2 is cleared to "0" by writing data to the SBI0DBR or reading data from the SBI0DBR.
SCL0 (Bus)
SA6
Start condition
SA5
SA4
SA3
SA2
SA1
SA0
R/W
Slave address + Direction bit
SDA0 (Bus)
Output of an acknowledge signal
SDA0 pin
Writing or reading SBI0DBR
INTSBI0 Interrupt request
Figure 18-14 Changes in the Slave Address Match Detection Monitor
RA001
Page 276
TMP89FM42
18.4.13GENERAL CALL detection monitor
SBI0SR2 is set to "1" when SBI0CR1 is "0" and GENERAL CALL (all 8-bit received data is "0" immediately after a start condition) in a slave mode. Setting SBI0CR1 to "1" disables the subsequent slave address match and GENERAL CALL detections. SBI0SR2 remains at "0" even if a "GENERAL CALL" is received. SBI0SR2 is cleared to "0" when a start or stop condition is detected on a bus.
SCL (Bus)
1
2
3
4
5
6
7
8
9
SDA (Bus)
Start condition GENERAL CALL Stop condition
SDA0
Output of an acknowledge signal
SBI0SR2 INTSBI0 Interrupt request
Figure 18-15 Changes in the GENERAL CALL Detection Monitor
18.4.14Last received bit monitor
The SDA line value stored at the rising edge of the SCL line is set to SBI0SR2. In the acknowledge mode, immediately after an interrupt request is generated, an acknowledge signal is read by reading the contents of SBI0SR2.
SCL
1
2
3
4
5
6
7
8
9
SDA
D7
D6
D5
D4
D3
D2
D1
D0
Acknowledgment
SBI0SR2
D7
D6
D5
D4
D3
D2
D1
D
Acknowledgment
Figure 18-16 Changes in the Last Received Bit Monitor
18.4.15Slave address and address recognition mode specification
When the serial bus interface circuit is used in the I2C bus mode, clear I2C0AR to "0", and set I2C0AR to the slave address. When the serial bus interface circuit is used with a free data format not to recognize the slave address, set I2C0AR to "1". With a free data format, the slave address and the direction bit are not recognized, and they are processed as data from immediately after the start condition.
RA001
Page 277
18. Serial Bus Interface (SBI)
18.5 Data Transfer of I2C Bus TMP89FM42
18.5 Data Transfer of I2C Bus
18.5.1 Device initialization
Set POFFCR1 to "1". After confirming that the serial bus interface pin is high level, set SBI0CR2 to "1" to select the serial bus interface mode. Set SBI0CR1 to "1", SBI0CR1 to "0" and SBI0CR1 to "000" to count the number of clocks for an acknowledge signal, to enable the slave address match detection and the GENERAL CALL detection, and set the data length to 8 bits. Set THIGH and TLOW at SBI0CR1. Set a slave address at I2C0AR and set I2C0AR to "0" to select the I2C bus mode. Finally, set SBI0CR2, SBI0CR2 and SBI0CR2 to "0", SBI0CR2 to "1" and SBI0CR2 to "00" for specifying the default setting to a slave receiver mode.
Note:The initialization of a serial bus interface circuit must be complete within the time from all devices which are connected to a bus have initialized to and device does not generate a start condition. If not, the data can not be received correctly because the other device starts transferring before an end of the initialization of a serial bus interface circuit.
Example :Initialize a device
CHK_PORT: CMP JR LD LD LD LD (P2PRD), 0x0C NZ, CHK_PORT (SBI0CR2), 0x18 (SBI0CR1), 0x16 (I2C0AR), 0xa0 (SBI0CR2), 0x18 ; Selects the serial bus interface mode ; Selects the acknowledgment mode and sets SBI0CR1 to "110" ; Sets the slave address to 1010000 and selects the I2C bus mode ; Selects the slave receiver mode ; Checks whether the serial bus interface pin is at the high level
18.5.2 Start condition and slave address generation
Confirm a bus free status (SBI0SR2="0"). Set SBI0CR1 to "1" and specify a slave address and a direction bit to be transmitted to the SBI0DBR. By writing "1" to SBI0CR2, SBI0CR2, SBI0CR2 and SBI0CR2, the start condition is generated on a bus and then, the slave address and the direction bit which are set to the SBI0DBR are output. The time from generating the START condition until the falling SBI0 pin takes tHIGH. An interrupt request occurs at the 9th falling edge of a SCL clock cycle, and SBI0CR2 is cleared to "0". The SCL0 pin is pulled down to the low level while SBI0CR2 is "0". When an interrupt request occurs, SBI0CR2 changes by the hardware according to the direction bit only when an acknowledge signal is returned from the slave device.
Note 1: Do not write a slave address to the SBI0DBR while data is transferred. If data is written to the SBI0DBR, data to be output may be destroyed. Note 2: The bus free state must be confirmed by software within 98.0 s (the shortest transmitting time according to the standard mode I2C bus standard) or 23.7s (the shortest transmitting time according to the fast mode I2C bus standard) after setting of the slave address to be output. Only when the bus free state is confirmed, set "1" to SBI0CR2, SBI0CR2, SBI0CR2 and SBI0CR2 to generate the start conditions. If the writing of slave address and setting of SBI0CR2, SBI0CR2, SBI0CR2 and SBI0CR2 doesn't finish within 98.0s or 23.7s, the other masters may start the transferring and the slave address data written in SBI0DBR may be broken.
RA001
Page 278
TMP89FM42
Example :Generate the start condition
CHK_BB: TEST JR LD LD (SBI0SR2).BB F, CHK_BB (SBI0DBR), 0xcb (SBI0CR2), 0xf8 ; The transmission slave address 0x65 and the direction bit "1" ; Write "1" to SBI0CR2, , and to "1" ; Confirms that the bus is free
SCL0 pin
1
2
3
4
5
6
7
8
9
SDA0 pin
Start condition
SBI0CR1
Slave address + Direction bit
Acknowledgem ent signal from a slave
Interrupt request signal
SBI0CR2
SBI0CR2 is cleared to "0" when the direction bit is "1"and an acknowledge signal is returned.
Figure 18-17 Generating the Start Condition and the Slave Address
18.5.3 1-word data transfer
Check SBI0SR2 by the interrupt process after a 1-word data transfer is completed, and determine whether the mode is a master or slave.
18.5.3.1 When SBI0SR2 is "1" (Master mode)
Check SBI0SR2 and determine whether the mode is a transmitter or receiver.
(1)
When SBI0SR2 is "1" (Transmitter mode) Check SBI0SR2. When SBI0SR2 is "1", a receiver does not request data. Implement the process to generate a stop condition (described later) and terminate data transfer. When SBI0SR2 is "0", the receiver requests subsequent data. When the data to be transmitted subsequently is other than 8 bits, set SBI0CR1 again, set SBI0CR1 to "1", and write the transmitted data to SBI0DBR. After writing the data, SBI0CR2 becomes "1", a serial clock pulse is generated for transferring the subsequent 1-word data from the SCL0 pin, and then the 1-word data is transmitted from the SDA0 pin. After the data is transmitted, an interrupt request occurs. SBI0CR2 become "0" and the SCL0 pin is set to the low level. If the data to be transferred is more than one word in length, repeat the procedure from the SBI0SR2 checking above.
RA001
Page 279
18. Serial Bus Interface (SBI)
18.5 Data Transfer of I2C Bus TMP89FM42
SCL0 pin Write to SBI0DBR SDA0 pin
1
2
3
4
5
6
7
8
9
D7
D6
D5
D4
D3
D2
D1
D0
Acknowledge signal from the receiver
SBI0CR2
INTSBI0 Interrupt request
Figure 18-18 Example when SBI0CR1="000" and SBI0CR1="1"
(2)
When SBI0SR2 is "0" (Receiver mode) When the data to be transmitted subsequently is other than 8 bits, set SBI0CR1 again. Set SBI0CR1< ACK> to "1" and read the received data from the SBI0DBR (Reading data is undefined immediately after a slave address is sent). After the data is read, SBI0CR2 becomes "1" by writing the dummy data (0x00) to the SBI0DBR. The serial bus interface circuit outputs a serial clock pulse to the SCL0 pin to transfer the subsequent 1-word data and sets the SDA0 pin to "0" at the acknowledge signal timing. An interrupt request occurs and SBI0CR2 becomes "0". Then a serial bus interface circuit outputs a clock pulse for 1-word data transfer and the acknowledge signal by writing data to the SBI0DBR or setting SBI0CR2 to "1" after reading the received data.
Read SBI0DBR Write to SBI0DBR
SCL0 pin
9
1
2
3
4
5
6
7
8
9
SDA0 pin
D7
D6
D5
D4
D3
D2
D1
D0
New D7 Acknowledge signal to the transmitter
SBI0CR2
INTSBI0 Interrupt request
Figure 18-19 Example when SBI0CR1="000" and SBI0CR1="1"
To make the transmitter terminate transmission, execute following procedure before receiving a last data. 1. Read the received data. 2. Clear SBI0CR1 to "0" and set SBI0CR1 to "000". 3. To set SBI0CR2 to "1", write a dummy data (0x00) to SBI0DBR. Transfer 1-word data in which no clock is generated for an acknowledge signal by setting SBI0CR2 to "1". Next, execute following procedure. 1. Read the received data. RA001 Page 280
TMP89FM42
2. Clear SBI0CR1 to "0" and set SBI0CR1 to "001". 3. To set SBI0CR2 to "1", write a dummy data (0x00) to SBI0DBR. Transfer 1-bit data by setting SBI0CR1 to "1". In this case, since the master device is a receiver, the SDA line on a bus keeps the high level. The transmitter receives the high-level signal as a negative acknowledge signal. The receiver indicates to the transmitter that data transfer is complete. After 1-bit data is received and an interrupt request has occurred, generate the stop condition to terminate data transfer.
SCL0 pin
9
1
2
3
4
5
6
7
8
SDA0 pin
D7
D6
D5
D4
D3
D2
D1
D0
Negative acknowledge signal to the transmitter
SBI0CR
INTSBI0 Interrupt request After reading the received data, clear SBI0CR1 to "0" and writing the dummy data (0x00) After reading the reveived data, set SBI0CR1 to "001" and write dummy data (0x00)
Figure 18-20 Termination of Data Transfer in the Master Receiver Mode
18.5.3.2 When SBI0SR2 is "0" (Slave mode)
In the slave mode, a serial bus interface circuit operates either in the normal slave mode or in the slave mode after losing arbitration. In the slave mode, the conditions of generating the serial bus interface interrupt request (INTSBI0) are follows: * At the end of the acknowledge signal when the received slave address matches the value set by the I2C0AR with SBI0CR1 set at "0" * At the end of the acknowledge signal when a "GENERAL CALL" is received with SBI0CR1 set at "0" * At the end of transferring or receiving after matching of slave address or receiving of "GENERAL CALL" The serial bus interface circuit changes to the slave mode if arbitration is lost in the master mode. And an interrupt request occurs when the word data transfer terminates after losing arbitration. The generation of the interrupt request and the behavior of SBI0CR2 after losing arbitration are shown in Table 184.
RA001
Page 281
18. Serial Bus Interface (SBI)
18.5 Data Transfer of I2C Bus TMP89FM42
Table 18-4 The Behavior of an interrupt request and SBI0CR2 After Losing Arbitration
When the Arbitration Lost Occurs during Transmission of Slave Address as a Master interrupt request SBI0CR2 When the Arbitration Lost Occurs during Transmission of Data as Master Transmitter
An interrupt request is generated at the termination of word-data transfer. SBI0CR2 is cleared to "0".
When an interrupt request occurs, SBI0CR2 is reset to "0", and the SCL0 pin is set to the low level. Either writing data to the SBI0DBR or setting SBI0CR2 to "1" releases the SCL0 pin after taking tLOW. Check SBI0SR2, SBI0SR2, SBI0SR2 and SBI0SR2 and implement processes according to conditions listed in Table 18-5. Table 18-5 Operation in the Slave Mode
SBI0SR2 SBI0SR2 SBI0SR2 SBI0SR2 Conditions The serial bus interface circuit loses arbitration when transmitting a slave address, and receives a slave address of which the value of the direction bit sent from another master is "1". In the slave receiver mode, the serial bus interface circuit receives a slave address of which the value of the direction bit sent from the master is "1". Process
1
1
0
Set the number of bits in 1 word to SBI0CR1 and write the transmitted data to the SBI0DBR.
1 1
0
0 0 0 In the slave transmitter mode, the serial bus interface circuit finishes the transmission of 1-word data
Check SBI0SR2. If it is set to "1", set SBI0CR2 to "1" since the receiver does not request subsequent data. Then, clear SBI0CR2 to "0" to release the bus. If SBI0SR2 is set to "0", set the number of bits in 1 word to SBI0CR1 and write the transmitted data to SBI0DBR since the receiver requests subsequent data.
1
1/0
1
The serial bus interface circuit loses arbitration when transmitting a slave address, and receives a slave address of which the value of the direction bit sent from another master is "0" or receives a "GENERAL CALL". The serial bus interface circuit loses arbitration when transmitting a slave address or data, and terminates transferring the word data. In the slave receiver mode, the serial bus interface circuit receives a slave address of which the value of the direction bit sent from the master is "0" or receives "GENERAL CALL". In the slave receiver mode, the serial bus interface circuit terminates the receipt of 1-word data.
Write the dummy data (0x00) to the SBI0DBR to set SBI0CR2 to "1", or write "1" to SBI0CR2.
0 0
0
The serial bus interface circuit is changed to the slave mode. Write the dummy data (0x00) to the SBI0DBR to clear SBI0SR2 to "0" and set SBI0CR2 to "1".
1 0
1/0
Write the dummy data (0x00) to the SBI0DBR to set SBI0CR2 to "1", or write "1" to SBI0CR2.
0
1/0
Set the number of bits in 1-word to SBI0CR1, read the received data from the SBI0DBR and write the dummy data (0x00).
Note: In the slave mode, if the slave address set in I2C0AR is "0x00", a START Byte "0x01" in I2C bus standard is received, the device detects slave address match and SBI0CR2 is set to "1". Do not set I2C0AR to "0x00".
RA001
Page 282
TMP89FM42
18.5.4 Stop condition generation
When SBI0CR2 is "1", a sequence of generating a stop condition is started by setting "1" to SBI0CR2, SBI0CR2 and SBI0CR2 and clearing SBI0CR2 to "0". Do not modify the contents of SBI0CR2, SBI0CR2, SBI0CR2 and SBI0CR2 until a stop condition is generated on a bus. When a SCL line on a bus is pulled down by other devices, a serial bus interface circuit generates a stop condition after a SCL line is released. The time from the releasing SCL line until the generating the STOP condition takes tHIGH.
Example :Generate the stop condition
LD CHK_BB: TEST JR (SBI0CR2), 0xD8 (SBI0SR2).BB T, CHK_BB ; Sets SBI0CR2, and to "1" and SBI0CR2 to "0" ;Waits until the bus is set free
SBI0CR2="1" SBI0CR2="1" SBI0CR2="0" SBI0CR2="1"
If the SCL of the bus is pulled down by other devices, the stop condition is generated after it is released Stop condition
SCL0 pin
SCL (Bus)
SDA0 pin
SBI0CR2
SBI0SR2
Figure 18-21 Stop Condition Generation
18.5.5 Restart
Restart is used to change the direction of data transfer between a master device and a slave device during transferring data. The following explains how to restart the serial bus interface circuit. Clear SBI0CR2, SBI0CR2 and SBI0CR2 to "0" and set SBI0CR2 to "1". The SDA0 pin retains the high level and the SCL0 pin is released. Since this is not a stop condition, the bus is assumed to be in a busy state from other devices. Check SBI0SR2 until it becomes "0" to check that the SCL0 pin of the serial bus interface circuit is released.
RA001
Page 283
18. Serial Bus Interface (SBI)
18.5 Data Transfer of I2C Bus TMP89FM42
Check SBI0SR2 until it becomes "1" to check that the SCL line on the bus is not pulled down to the low level by other devices. After confirming that the bus stays in a free state, generate a start condition in the procedure "18.5.2 Start condition and slave address generation". In order to meet the setup time at a restart, take at least 4.7s of waiting time by the software in the standard mode I2C bus standard or at least 0.6s of waiting time in the fast mode I2C bus standard from the time of restarting to confirm that a bus is free until the time to generate a start condition.
Note:When the master is in the receiver mode, it is necessary to stop the data transmission from the slave device before the STOP condition is generated. To stop the transmission, the master device make the slave device receiving a negative acknowledge. Therefore, SBI0SR2 is "1" before generating the Restart and it can not be confirmed that SCL line is not pulled down by other devices. Please confirm the SCL line state by reading the port.
Example :Generate a restart
LD CHK_BB: TEST JR CHK_LRB: TEST JR (SBI0CR2), 0x18 (SBI0SR2).BB T, CHK_BB (SBI0SR2).LRB F, CHK_LRB . . . LD (SBI0CR2), 0xf8 ; Sets SBI0CR2, , and to "1" ; Wait time process by the software ; Waits until SBI0SR2 becomes "1" ; Sets SBI0CR2, and to "0" and SBI0CR2 to "1" ; Waits until SBI0SR2 becomes "0"
SBI0CR2="0" SBI0CR2="0" SBI0CR2="0" SBI0CR2="1"
SBI0CR2="1" SBI0CR2="1" SBI0CR2="1" SBI0CR2="1"
4.7 s min. in the normal mode or 0.6 s min. in the fast mode
Start condition
SCL (Bus)
SCL0 pin
SDA0 pin
SBI0SR2
SBI0SR2
SBI0CR2
Figure 18-22 Timing Diagram When Restarting
RA001
Page 284
TMP89FM42
18.6 AC Specifications
The AC specifications are as listed below. The operating mode (fast or standard) mode should be selected suitable for frequency of fcgck. For these operating mode, refer to the following table. Table 18-6 AC Specifications (Circuit Output Timing)
Standard mode Parameter Symbol MIN. SCL clock frequency Hold time (re)start condition. This period is followed by generation of the first clock pulse. Low-level period of SCL clock (output) High-level period of SCL clock (output) Low-level period of SCL clock (input) High-level period of SCL clock (input) Restart condition setup time Data hold time Data setup time Rising time of SDA and SCL signals Falling time of SDA and SCL signals Stop condition setup time Bus free time between the stop condition and the start condition Time before rising of SCL after SBICR2 is changed from "0" to "1" fSCL 0 MAX. fcgck / (m+n) MIN. 0 MAX. fcgck / (m+n) kHz Fast mode Unit
tHD;STA
m / fcgck
-
m / fcgck
-
s
tLOW tHIGH tLOW tHIGH tSU;STA tHD;DAT tSU;DAT tr tf tSU;STO tBUF
n / fcgck m / fcgck 5 / fcgck 3 / fcgck Depends on the software 0 250 m / fcgck Depends on the software
5 / fcgck 1000 300 -
n / fcgck m / fcgck 5 / fcgck 3 / fcgck Depends on the software 0 100 m / fcgck Depends on the software
5 / fcgck 300 300 -
s s s s s s ns ns ns s s
tSU;SCL
n / fcgck
-
n / fcgck
-
s
Note: For m and n, refer to"18.4.4.1 Clock source".
tf t LOW tr
t SU;DAT tf
t HD;STA
tf
t BUF
t HD;STA t HD;DAT t HIGH
t SU;STA
t SU;STO
Figure 18-23 Definition of Timing (No. 1)
RA001
Page 285
18. Serial Bus Interface (SBI)
18.6 AC Specifications TMP89FM42
SCL
SBICR2 t SU;SCL
Figure 18-24 Definition of Timing (No. 2)
RA001
Page 286
TMP89FM42
18.7 Revision History
Rev
Description " Serial bus interface control register 1" Revised SCK description. Added Note5. "18.6 AC Specifications" Revised fcgck description.
RA001 "Table 18-6 AC Specifications (Circuit Output Timing)" Revised value of "SCL clock frequency". Revised from "normal mode" to "standard mode".
RA001
Page 287
18. Serial Bus Interface (SBI)
18.7 Revision History TMP89FM42
RA001
Page 288
TMP89FM42
19. Key-on Wakeup (KWU)
The key-on wakeup is a function for releasing the STOP mode at the STOP pin or at pins KWI7 through KWI0.
19.1 Configuration
SYSCR1
Stop mode Y0 release signal 1 (to be released Selector if set to "1")
S
Rising edge detection
Port
STOP
Port Port Port Port
KWI0 KWI1 KWI2 KWI3
KWUCR0 (0x0FC4) 7 6 5 4 3 2 1 0 Port Port Port Port KWI4 KWI5 KWI6 KWI7
KWUCR1 (0x0FC5) 7 6 5 4 3 2 1 0
Figure 19-1 Key-on Wakeup Circuit
RA000
Page 289
19. Key-on Wakeup (KWU)
19.1 Configuration TMP89FM42
19.2 Control
Key-on wakeup control registers (KWUCR0 and KWUCR1) can be configured to designate the key-on wakeup pins (KWI7 through KWI0) as STOP mode release pins and to specify the STOP mode release levels of each of these designated pins. Key-on wakeup control register 0
KWUCR0 (0x0FC4) Bit Symbol Read/Write After reset 7 KW3LE R/W 0 6 KW3EN R/W 0 5 KW2LE R/W 0 4 KW2EN R/W 0 3 KW1LE R/W 0 2 KW1EN R/W 0 1 KW0LE R/W 0 0 KW0EN R/W 0
KW3LE
STOP mode release level of KWI3 pin Input enable/disable control of KWI3 pin STOP mode release level of KWI2 pin Input enable/disable control of KWI2 pin STOP mode release level of KWI1 Input enable/disable control of KWI1 pin STOP mode release level of KWI0 pin Input enable/disable control of KWI0 pin
0: 1: 0: 1: 0: 1: 0: 1: 0: 1: 0: 1: 0: 1: 0: 1:
Low level High level Disable Enable Low level High level Disable Enable Low level High level Disable Enable Low level High level Disable Enable
KW3EN
KW2LE
KW2EN
KW1LE
KW1EN
KW0LE
KW0EN
Key-on wakeup control register 1
KWUCR1 (0x0FC5) Bit Symbol Read/Write After reset 7 KW7LE R/W 0 6 KW7EN R/W 0 5 KW6LE R/W 0 4 KW6EN R/W 0 3 KW5LE R/W 0 2 KW5EN R/W 0 1 KW4LE R/W 0 0 KW4EN R/W 0
KW7LE
STOP mode release level of KWI7 pin Input enable/disable control of KWI7 pin STOP mode release level of KWI6 pin Input enable/disable control of KWI6 pin STOP mode release level of KWI5 pin Input enable/disable control of KWI5 pin STOP mode release level of KWI4 pin Input enable/disable control of KWI4 pin
0: 1: 0: 1: 0: 1: 0: 1: 0: 1: 0: 1: 0: 1: 0: 1:
Low level High level Disable Enable Low level High level Disable Enable Low level High level Disable Enable Low level High level Disable Enable
KW7EN
KW6LE
KW6EN
KW5LE
KW5EN
KW4LE
KW4EN
RA000
Page 290
TMP89FM42
19.3 Functions
By using the key-on wakeup function, the STOP mode can be released at a STOP pin or at KWIm pin (m: 0 through 7). After resetting, the STOP pin is the only STOP mode release pin. To designate the KWIm pin as a STOP mode release pin, therefore, it is necessary to configure the key-on wakeup control register (KWUCRn) (n: 0 or 1). Because the STOP pin lacks a function for disabling inputs, it can be designated as a pin for receiving a STOP mode release signal, irrespective of whether the key-on wakeup function is used or not. * Setting KWUCRn and P4PU registers To designate a key-on wakeup pin (KWIm) as a STOP mode release pin, set KWUCRn to "1". After KWIm pin is set to "1" at KWUCRn, a specific STOP mode release level can be specified for this pin at KWUCRn. If KWUCRn is set to "0", STOP mode is released when an input is at a low level. If it is set to "1", STOP mode is released when an input is at a high level. For example, if you want to release STOP mode by inputting a high-level signal into a KWI0 pin, set KWUCR0 to "1", " and KWUCR0 to "1". Each KWIm pin can be connected to internal pull-up resistors. Before connecting to internal pull-up resistors, the corresponding bits in the pull-up control register (P4PU) at port P4 must be set to "1". * Starting STOP mode To start the STOP mode, set SYSCR1 to "1" (level release mode), and SYSCR1 to "1". To use the key-on wakeup function, do not set SYSCR1 to "0" (edge release mode). If the key-on wakeup function is used in edge release mode, STOP mode cannot be released, although a rising edge is input into the STOP pin. This is because the KWIm pin enabling inputs to be received is at a release level after the STOP mode starts. * Releasing STOP mode To release STOP mode, input a high-level signal into the STOP pin or input a specific release level into the KWIm pin for which receipt of inputs is enabled. If you want to release STOP mode at the KWIm pin, rather than the STOP pin, continue inputting a low-level signal into the STOP pin throughout the period from when the STOP mode is started to when it is released. If the STOP pin or KWIm pin is already at a release level when the STOP mode starts, the following instruction will be executed without starting the STOP mode (with no warm-up performed).
Note 1: If an analog voltage is applied to KWIm pin for which receipt of inputs is enabled by the key-on wakeup control register (KWUCRn) setting, a penetration current will flow. Therefore, in this case, the analog voltage should be not applied to this pin.
Table 19-1 STOP Mode Release Level (edge)
Release level (edge) Pin name SYSCR1="1" (level release mode) KWUCRn="0"
STOP
SYSCR1="0" (edge release mode)
KWUCRn="1" Rising edge "H" level Don't use
"H" level "L" level
KWIm
RA000
Page 291
19. Key-on Wakeup (KWU)
19.1 Configuration TMP89FM42
Example :A case in which STOP mode is started with the release level of the STOP pin set to a high level and the release level of KWI0 set to a low level (connected to an internal pull-up resistor of the KWI0 pin)
DI SET LD (P4PU).0 (KWUCR0), 00000001B ; IMF0 ; KWI0 (P40) connected to a pull-up resistor ; the KWI0 pin is set to enable inputs, and its release level is set to a low level. ; Starting in level release mode
LD
(SYSCR1), 10100000B
RA000
Page 292
TMP89FM42
20. 10-bit AD Converter (ADC)
The TMP89FM42 has a 10-bit successive approximation type AD converter.
20.1 Configuration
The circuit configuration of the 10-bit AD converter is shown in Figure 20-1. It consists of control registers ADCCR1 and ADCCR2, converted value registers ADCDRL and ADCDRH, a DA converter, a sample-hold circuit, a comparator, a successive comparison circuit, etc.
DA converter
VAREF/AVDD VSS
R/2 Input selector
AIN0
R Reference voltage
R/2
Sample-hold circuit
A
Y 10 Analog comparator
AIN7
n S EN 4 ADRS SAIN AINDS
Successive approximation circuit 10 Selector 8 ADCDRL 8 ADCDRH INTADC
Shift clock Control circuit EOCF ADBF 3 2 AMD ACK ADCCR1 ADCCR2 RSEL
AD converter control registers 1 and 2
AD converted value registers 1 and 2
Figure 20-1 10-bit AD Converter
Note 1: Before using the AD converter, set an appropriate value to the I/O port register which is also used as an analog input port. For details, see the section on "I/O ports". Note 2: The DA converter current (IREF) is automatically cut off at times other than during AD conversion.
RA001
Page 293
20. 10-bit AD Converter (ADC)
20.2 Control TMP89FM42
20.2 Control
The AD converter consists of the following four registers: 1. AD converter control register 1 (ADCCR1) This register selects an analog channel in which to perform AD conversion, selects an AD conversion operation mode, and controls the start of the AD converter. 2. AD converter control register 2 (ADCCR2) This register selects the AD conversion time, and monitors the operating status of the AD converter. 3. AD converted value registers (ADCDRH and ADCDRL) These registers store the digital values generated by the AD converter.
RA001
Page 294
TMP89FM42
AD converter control register 1
ADCCR1 (0x0034) Bit Symbol Read/Write After reset 7 ADRS R/W 0 0 6 AMD R/W 0 5 4 AINEN R/W 0 0 0 3 2 SAIN R/W 0 0 1 0
ADRS
AD conversion start
0: 1: 00: 01: 10: 11: 0: 1: 0000: 0001: 0010: 0011: 0100: 0101: 0110: 0111: 1000: 1001: 1010: 1011: 1100: 1101: 1110: 1111:
AD conversion start AD operation disable, forcibly stop AD operation Single mode Reserved Repeat mode Analog input disable Analog input enable AIN0 AIN1 AIN2 AIN3 AIN4 AIN5 AIN6 AIN7 Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved
AMD
AD operating mode
AINEN
Analog input control
SAIN
Analog input channel select
Note 1: Do not perform the following operations on the ADCCR1 register while AD conversion is being executed (ADCCR2="1"). - Changing SAIN - Setting AINEN to "0" - Changing AMD (except a forced stop by setting AMD to "00") - Setting ADRS to "1" Note 2: If you want to disable all analog input channels, set AINEN to "0". Note 3: Although analog input pins are also used as input/output ports, it is recommended for the purpose of maintaining the accuracy of AD conversion that you do not execute input/output instructions during AD conversion. Additionally, do not input widely varying signals into the ports adjacent to analog input pins. Note 4: When STOP, IDLE0 or SLOW mode is started, ADRS, AMD and AINEN are initialized to "0". If you use the AD converter after returning to NORMAL mode, you must reconfigure ADRS, AMD and AINEN. Note 5: After the start of AD conversion, ADRS is automatically cleared to "0" ("0" is read).
RA001
Page 295
20. 10-bit AD Converter (ADC)
20.2 Control TMP89FM42
AD converter control register 2
ADCCR2 (0x0035) Bit Symbol Read/Write After reset 7 EOCF R 0 6 ADBF R 0 5 R 0 4 R 0 3 "0" W 0 0 2 1 ACK R/W 0 0 0
EOCF
AD conversion end flag
0: 1: 0: 1: 000: 001: 010: 011: 100: 101: 110: 111:
Before conversion or during conversion Conversion end AD conversion being halted AD conversion being executed 39/fcgck 78/fcgck 156/fcgck 312/fcgck 624/fcgck 1248/fcgck Reserved Reserved
ADBF
AD conversion BUSY flag
ACK
AD conversion time select (examples of AD conversion time are shown in the table below)
Note 1: Make sure that you make the ACK setting when AD conversion is in a halt condition (ADCCR2="0"). Note 2: Make sure that you write "0" to bit 3 of ADCCR2. Note 3: If STOP, IDLE0 or SLOW mode is started, EOCF and ADBF are initialized to "0". Note 4: If the AD converted value register (ADCDRH) is read, EOCF is cleared to "0". It is also cleared to "0" if AD conversion is started (ADCCR1="1") without reading ADCDRH after completing AD conversion in single mode. Note 5: If an instruction to read ADCCR2 is executed, 0 is read from bits 3 through 5.
Table 20-1 ACK Settings and Conversion Times Relative to Frequencies
Frequency (fcgck) ACK setting 000 001 010 011 100 101 11* Conversion time 39/fcgck 78/fcgck 156/fcgck 312/fcgck 624/fcgck 1248/fcgck 10MHz 15.6 s 31.2 s 62.4 s 124.8 s 8MHz 19.5 s 39.0 s 78.0 s 156.0 s 4MHz 19.5 s 39.0 s 78.0 s 156.0 s 2MHz 19.5 s 39.0 s 78.0 s 156.0 s Reserved 5MHz 15.6 s 31.2 s 62.4 s 124.8 s 2.5MHz 15.6 s 31.2 s 62.4 s 124.8 s 1MHz 39.0 s 78.0 s 156.0 s 0.5MHz 78.0 s 156.0 s 0.25 MHz 156.0 s -
Note 1: Spaces indicated by "-" in the above table mean that it is prohibited to establish conversion times in these spaces. fcgck: High Frequency oscillation clock [Hz] Note 2: Above conversion times do not include the time shown below. - Time from when ADCCR1 is set to 1 to when AD conversion is started - Time from when AD conversion is finished to when a converted value is stored in ADCDRL and ADCDRH. If ACK = 00*, the longest conversion time is 10/fcgck (s). If ACK = 01*, it is 32/fcgck (s). If ACK = 10*, it is 128/fcgck(s). Note 3: The conversion time must be longer than the following time by analog reference voltage (VAREF). - VAREF = 4.5 to 5.5 V - VAREF = 2.7 to 5.5 V - VAREF = 2.2 to 5.5 V 15.6 s or longer 31.2 s or longer 124.8 s or longer
RA001
Page 296
TMP89FM42
AD converted value register (lower side)
ADCDRL (0x0036) Bit Symbol Read/Write After reset 7 AD07 R 0 6 AD06 R 0 5 AD05 R 0 4 AD04 R 0 3 AD03 R 0 2 AD02 R 0 1 AD01 R 0 0 AD00 R 0
AD converted value register (upper side)
ADCDRH (0x0037) Bit Symbol Read/Write After reset 7 R 0 6 R 0 5 R 0 4 R 0 3 R 0 2 R 0 1 AD09 R 0 0 AD08 R 0
Note 1: A read of ADCDRL or ADCDRH must be read after the INTADC interrupt is generated or after ADCCR2 becomes "1". Note 2: In single mode, do not read ADCDRL or ADCDRH during AD conversion (ADCCR2="1"). (If AD conversion is finished in the interim between a read of ADCDRL and a read of ADCDRH, the INTADC interrupt request is canceled, and the conversion result is lost.) Note 3: If STOP, IDLE0 or SLOW mode is started, ADCDRL and ADCDRH are initialized to "0". Note 4: If ADCCR1 is set to "00", ADCDRL and ADCDRH are initialized to "0". Note 5: If an instruction to read ADCDRH is executed, "0" is read from bits 7 through 2. Note 6: If AD conversion is finished in repeat mode in the interim between a read of ADCDRL and a read of ADCDRH, the previous converted value is retained without overwriting the AD converted value register. In this case, the INTADC interrupt request is canceled, and the conversion result is lost.
RA001
Page 297
20. 10-bit AD Converter (ADC)
20.3 Functions TMP89FM42
20.3 Functions
The 10-bit AD converter operates in either single mode in which AD conversion is performed only once or repeat mode in which AD conversion is performed repeatedly.
20.3.1 Single mode
In single mode, the voltage at a designated analog input pin is AD converted only once. Setting ADCCR1 to "1" after setting ADCCR1 to "01" allows AD conversion to start. ADCCR1 is automatically cleared after the start of AD conversion. As AD conversion starts, ADCCR2 is set to "1". It is cleared to "0" if AD conversion is finished or if AD conversion is forced to stop. After AD conversion is finished, the conversion result is stored in the AD converted value registers (ADCDRL and ADCDRH), ADCCR2 is set to "1", and the AD conversion finished interrupt (INTADC) is generated. The AD converted value registers (ADCDRL and ADCDRH) should be usually read according to the INTADC interrupt processing routine. If the upper side (ADCDRH) of the AD converted value register is read, ADCCR2 is cleared to "0".
Note:Do not perform the following operations on the ADCCR1 register when AD conversion is being executed (ADCCR2="1"). If the following operations are performed, there is the possibility that AD conversion may not be executed properly. * Changing the ADCCR1 setting * Setting ADCCR1 to "0" * Changing the ADCCR1 setting (except a forced stop by setting AMD to "00") * Setting ADCCR1 to "1"
AD conversion start ADCCR1
AD conversion start
ADCCR2
Status of ADCDRL and ADCDRH ADCCR2
Indeterminate
Result of the first conversion
Result of the second conversion Clearing EOCF based on the conversion result
INTADC interrupt request Read of ADCDRH Read of conversion result Read of ADCDRL Read of conversion result Read of conversion result Read of conversion result
Figure 20-2 Single Mode
20.3.2 Repeat mode
In repeat mode, the voltage at an analog input pin designated at ADCCR1 is AD converted repeatedly. Setting ADCCR1 to "1" after setting ADCCR1 to "11" allows AD conversion to start. After the start of AD conversion, ADCCR1 is automatically cleared. After the first AD conversion is finished, the conversion result is stored in the AD converted value registers (ADCDRL and ADCDRH), ADCCR2 is set to "1", and the AD conversion finished interrupt (INTADC) is generated. After this interrupt is generated, the second (next) AD conversion starts immediately.
RA001
Page 298
TMP89FM42
The AD converted value registers (ADCDRL and ADDRH) should be read before the next AD conversion is finished. If the next AD conversion is finished in the interim between a read of ADCDRL and a read of ADCDRH, the previous converted value is retained without overwriting the AD converted value registers (ADCDRL and ADCDRH). In this case, the INTADC interrupt request is not generated, and the conversion result is lost. (See Figure 20-3.) To stop AD conversion, write "00" (AD operation disable) to ADCCR1. As "00" is written to ADCCR1, AD conversion stops immediately. In this case, the converted value is not stored in the AD converted value register. As AD conversion starts, ADCCR2 is set to "1". It is cleared to "0" if "00" is written to AMD.
ADCCR1 AD conversion start ADCCR1
"11"
"00"
Conversion operation
Result of the 2nd conversion
Result of the 3rd conversion
Result of the 4th conversion
AD conversion is suspended. The conversion result is not stored.
Status of ADCDRL and ADCDRH ADCCR2
Indeterminate
Result of the 1st conversion
Result of the 3rd conversion
Result of the 4th conversion
INTADC interrupt Read of ADCDRH Read of ADCDRL The INTADC interrupt request is not generated in the interim between a read of ADCDRL and a read of ADCDRH. Read of conversion result Read of conversion result Read of conversion result Read of conversion result
A read of the conversion result will clear EOCF.
Read of conversion result Read of conversion result
Figure 20-3 Repeat Mode
20.3.3 AD operation disable and forced stop of AD operation
If you want to force the AD converter to stop when AD conversion is ongoing in single mode or if you want to stop the AD converter when AD conversion is ongoing in repeat mode, set ADCCR1 to "00". If ADCCR1 is set to "00", registers ADCCR2, ADCCR2, ADCDRL, and ADCDRH are initialized to "0".
RA001
Page 299
20. 10-bit AD Converter (ADC)
20.4 Register Setting TMP89FM42
20.4 Register Setting
1. Set the AD converter control register 1 (ADCCR1) as described below: * From the AD input channel select (SAIN), select the channel in which AD conversion is to be performed. * Set the analog input control (AINEN) to "Analog input enable". * At AMD, specify the AD operating mode (single or repeat mode). 2. Set the AD converter control register 2 (ADCCR2) as described below: * At the AD conversion time (ACK), specify the AD conversion time. For information on how to specify the conversion time, refer to the AD converter control register 2 and Table 20-1. 3. After the above two steps are completed, set "1" on the AD conversion start (ADRS) of the AD converter control register 1 (ADCCR1), and AD conversion starts immediately if single mode is selected. 4. As AD conversion is finished, the AD conversion end flag (EOCF) of the AD converter control register 2 (ADCCR2) is set to "1", the AD conversion result is stored in the AD converted value registers (ADCDRH and ADCDRL), and the INTADC interrupt request is generated. 5. After the conversion result is read from the AD converted value register (ADCDRH), EOCF is cleared to "0". EOCF will also be cleared to "0" if AD conversion is performed once again before reading the AD converted value register (ADCDRH). In this case, the previous conversion result is retained until AD conversion is finished.
Example: After selecting the conversion time 15.6 s at 10 MHz and the analog input channel AIN3 pin, perform AD conversion once. After checking EOCF, store the conversion result in the HL register. The operation mode is single mode.
: (Port setting) ; Before setting AD converter registers, make an appropriate port register setting.(For further details, refer to the section that describes I/O ports.) ; Select AIN3. ; Select conversion time (156/fcgck) and operation mode. ; ADRS = 1 (AD conversion start) ; EOCF = 1 ? ; Read result data
LD LD SET SLOOP : TEST JRS LD
(ADCCR1), 0y00110011 (ADCCR2), 0y00000011 (ADCCR1). 7 (ADCCR2). 7 T, SLOOP HL, (ADCDRL)
20.5 Starting STOP/IDLE0/SLOW Modes
If STOP/IDLE0/SLOW mode is started, registers ADCCR1, ADCCR2, ADCDRL and ADCDRH are initialized to "0". If any of these modes is started during AD conversion, AD conversion is suspended, and the AD converter stops (registers are likewise initialized). When restored from STOP/ IDLE0/ SLOW mode, AD conversion is not automatically restarted. Therefore, registers must be reconfigured as necessary. If STOP/IDLE0/SLOW mode is started during AD conversion, analog reference voltage is automatically disconnected and, therefore, there is no possibility of current flowing into the analog reference voltage.
RA001
Page 300
TMP89FM42
20.6 Analog Input Voltage and AD Conversion Result
Analog input voltages correspond to AD-converted, 10-bit digital values, as shown in Figure 20-4.
3FFH 3FEH 3FDH
AD-converted value
03H 02H 01H
VAREF/AVDD - VSS
0
1
2
3
1021 1022 1023 1024
1024
Analog input voltage
Figure 20-4 Relationships between Analog Input Voltages and AD-converted Values (typical values)
RA001
Page 301
20. 10-bit AD Converter (ADC)
20.7 Precautions about the AD Converter TMP89FM42
20.7 Precautions about the AD Converter
20.7.1 Analog input pin voltage range
Analog input pins (AIN0 through AIN7) should be used at voltages from VAREF to VSS. If any voltage outside this range is applied to one of the analog input pins, the converted value on that pin becomes uncertain, and converted values on other pins will also be affected.
20.7.2 Analog input pins used as input/output ports
Analog input pins (AIN0 to AIN7) are also used as input/output ports. In using one of analog input pins (ports) to execute AD conversion, input/output instructions at all other pins (ports) must not be executed. If they are executed, there is the possibility that the accuracy of AD conversion may deteriorate. This also applies to pins other than analog input pins; if one pin receives inputs or generates outputs, noise may occur and its adjacent pins may be affected by that noise.
20.7.3 Noise countermeasure
The internal equivalent circuit of the analog input pins is shown in Figure 20-5. The higher the output impedance of the analog input source, the more susceptible it becomes to noise. Therefore, make sure the output impedance of the signal source in your design is 5 k or less. It is recommended that a capacitor be attached externally.
rnal resistance:
Analog comparator 5 k (max) AINi
Internal resistance:
#!Undefined!# k (typ) 5 k (typ)
Analog comparator
Permissible signal rnal capacitance: source impedance: DA converter Note) i = 7 to 0
Internal capacitance:
C = 22 pF (typ.)
DA converter
Figure 20-5 Analog Input Equivalent Circuit and Example of Input Pin Processing
RA001
Page 302
TMP89FM42
21. Flash Memory
The TMP89FM42 has flash memory of 32768 bytes. A write and erase to be performed on flash memory can be controlled in the following three modes: - MCU mode In MCU mode, the flash memory is accessed by the CPU control, and the flash memory can be executed the erasing and writing without affecting the operations of a running application. Therefore, this mode is used for software debugging and firmware change after shipment of the TMP89FM42. - Serial PROM mode In serial PROM mode, the flash memory is accessed by the CPU control. Use of the serial interface (UART and SIO) enables the flash memory to be controlled by the small number of pins. The TMP89FM42 used in serial PROM mode supports on-board programming, which enables users to program flash memory after the microcontroller is mounted on a user board. - Parallel PROM mode The parallel PROM mode allows the flash memory to be accessed as a stand-alone flash memory by the program writer provided by a third party. High-speed access to the flash memory is available by controlling address and data signals directly. To receive a support service for the program writer, please ask a Toshiba sales representative.
In MCU and serial PROM modes, flash memory control registers (FLSCR1 and FLSCR2) are used to control the flash memory. This chapter describes how to access the flash memory using the MCU and serial PROM modes.
RA003
Page 303
21. Flash Memory
TMP89FM42
21.1 Flash Memory Control
The flash memory is controlled by the flash memory control register 1 (FLSCR1), flash memory control register 2 (FLSCR2), and flash memory standby control register (FLSSTB). Flash memory control register 1
FLSCR1 (0x0FD0) Bit Symbol Read/Write After reset 0 7 6 FLSMD R/W 1 0 5 4 BAREA R/W 0 0 3 FAREA R/W 0 2 1 R/W 0 0 R/W 0
FLSMD
Flash memory command sequence and toggle control
010: 101: Others:
Disable command sequence and toggle execution Enable command sequence and toggle execution Reserved MCU mode Serial PROM mode Show BOOTROM
BAREA
BOOTROM mapping control
0: 1: 00:
Hide BOOTROM Show BOOTROM
Assign the data area 0x8000 through 0xFFFF to the data area 0x8000 through 0xFFFF (standard mapping). Reserved Assign the code area 0x8000 through 0xFFFF to the data area 0x8000 through 0xFFFF. Reserved
01: FAREA Flash memory area select control 10:
11:
Note 1: Note 2:
It is prohibited to make a setting in "Reserved". The flash memory control register 1 has a double-buffer structure comprised of the register FLSCR1 and a shift register. Writing "0xD5" to the register FLSCR2 allows a register setting to be reflected and take effect in the shift register. This means that a register setting value does not take effect until "0xD5" is written to the register FLSCR2. The value of the shift register can be checked by reading the register FLSCRM. FLSMD must be set to either "0y010" or "0y101".
Note 3:
Flash memory control register 2
FLSCR2 (0x0FD1) Bit Symbol Read/Write After reset * * * * 7 6 5 4 CR1EN W * * * * 3 2 1 0
CR1EN
FLSCR1 register enable/disable control
0xD5 Others
Enable a change in the FLSCR1 setting Reserved
Note 1: If "0xD5" is set on FLSCR2 with FLSCR1 set to "101", the flash memory goes into an active state, and MCU consumes the same amount of current as it does during a read.
RA003
Page 304
TMP89FM42
Flash memory control register 1 monitor
FLSCRM (0x0FD1) Bit Symbol Read/Write After reset R 0 R 0 7 6 5 FLSMDM R 0 4 BAREAM R 0 0 3 FAREAM R 0 0 2 1 ROMSELM R 0 0
FLSMDM BAREAM FAREAM ROMSELM
Monitoring of FLSCR1 status Monitoring of FLSCR1 status Monitoring of FLSCR1 status Monitoring of FLSCR1 status
0 1
FLSCR1="101" setting disabled FLSCR1="101" setting enabled Value of currently enabled FLSCR1 Value of currently enabled FLSCR1 Value of currently enabled FLSCR1
Note 1: FLSCRM is the register that checks the value of the shift register of the flash memory control register 1. Note 2: FLSMDM turns into "1" only if FLSMD="101" becomes effective. Note 3: If an instruction to read FLSCRM is executed, "0" is read from bits 7 and 6. Note 4: In serial PROM mode, "1" is always read from BAREAM.
RA003
Page 305
21. Flash Memory
TMP89FM42
Flash memory standby control register
FLSSTB (0x0FD2) Bit Symbol Read/Write After reset R 0 R 0 R 0 R 0 R 0 R 0 R 0 7 6 5 4 3 2 1 0 FSTB W 0
FSTB
Flash memory standby control
0 1
Disable flash memory standby Enable flash memory standby
Note 1: A value can be written to FSTB only by using a program that resides in RAM. A value written using a program residing in the flash memory will be invalidated. Note 2: If FSTB is set to "1", do not execute instructions to fetch or read data from or write data to the flash memory. If they are executed, a flash standby reset will occur. Note 3: If an instruction to read FLSSTB is executed, "0" is read from bits 7 through 0.
Port input control register (this register works only in serial PROM mode)
SPCR (0x0FD3) Bit Symbol Read/Write After reset R 1 R 0 R 0 R 0 R 0 R 0 7 6 5 4 3 2 1 PIN1 R/W 0 0 PIN0 R/W 0
In serial PROM mode PIN1 Port input control (SCLK0 pin) in serial PROM mode Port input control (except RXD0, TXD0 and SCLK0) in serial PROM mode 0 1 0 1 Port input disabled Port input enabled Port input disabled Port input enabled
In MCU mode Input enabled for all ports Nonfunctional whatever settings are made "0" is read
PIN0
Note 1: A read or write can be performed on the SPCR register only in serial PROM mode. If a write is performed on this register in MCU mode, the port input control does not function. If a read is performed on the SPCR register in MCU mode, "0" is read from bits 7 through 0. Note 2: All I/O ports are controlled by PIN0, except the ports RXD0, TXD0 and SCLK0 which are used in serial PROM mode. By using PIN1, the SCLK0 pin can be configured separately from other pins.
RA003
Page 306
TMP89FM42
21.2 Functions
21.2.1 Flash memory command sequence execution and toggle control (FLSCR1 )
To prevent inadvertent writes to the flash memory due to program error or microcontroller malfunction, the execution of the flash memory command sequence and the toggle operation can be disabled (the flash memory can be write protected) by making an appropriate control register setting (write protect). To enable the execution of the command sequence and the toggle operation, set FLSCR1 to "0y101", and then set "0xD5" on FLSCR2. To disable the execution of the command sequence, set FLSCR1 to "0y010", and then set "0xD5" on FLSCR2. If the command sequence or the toggle operation is executed with the execution of the command sequence and the toggle operation set to "disable", the executed command sequence or toggle operation takes no effect. After a reset, FLSCR1 is initialized to "0y010" to disable the execution of the command sequence. FLSCR1 should normally be set to "0y010" except when a write or erase is to be performed on the flash memory.
Note 1: If "0xD5" is set on FLSCR2 with FLSCR1 set to "101", the flash memory goes into an active state, and MCU consumes the same amount of current as it does during a read. Note 2: If FLSCR1 is set to "disable", subsequent commands (write instructions) generated are rejected but a command sequence being executed is not initialized. If you want to set FLSCR1 to "disable", you must finish all command sequences and verify that the flash memory is ready to be read.
RA003
Page 307
21. Flash Memory
TMP89FM42
21.2.2 Flash memory area switching (FLSCR1)
To perform an erase or write on the flash memory, a memory transfer instruction (command sequence) must be executed. If a memory transfer instruction is used to read or write data, a read or write can be performed only on the data area. To perform an erase or write on the code area, therefore, part of the code area must be temporarily switched to the data area. This switching between data and code areas is performed by making the appropriate FLSCR1 setting. By setting "0xD5" on FLSCR2 after setting FLSCR1 to "10", 0x8000 through 0xFFFF (AREA C1) in the code area is mapped to 0x8000 through 0xFFFF (AREA D1) in the data area. To restore the flash memory to the initial state of mapping, set FLSCR1 to "00", and then set "0xD5" on FLSCR2. All flash memory areas can be accessed by performing the appropriate steps described above and then executing the memory transfer instruction on 0x8000 through 0xFFFF (AREA D1) in the data area. 0x8000 through 0xFFFF (AREA D1) in the data area and 0x8000 through 0xFFFF (AREA C1) in the code area are mirror areas; these two areas refer to the same physical address in memory. Therefore, an erase or write must be performed on one of these two mirror areas. For example, If a write is performed on 0x8000 in the data area with FLSCR1 set to "10" after performing a write on 0x8000 in the data area with FLSCR1 set to "00", data is overwritten. To write data to the flash memory that already has data written to it, existing data must first be erased from the flash memory by performing a sector erase or chip erase, and then data must be written. Additionally, access to areas to which memory is not assigned should be avoided by executing an instruction or specifying such an area by using jump or call instructions.
0x0000 0x0000
SFR RAM
0x0FFF
0x7FFF 0x8000
0x7FFF 0x8000
32768 bytes Flash AREA D1 Flash
32768 bytes AREA C1
0xFFFF
0xFFFF
Data area If FLSCR = "00"
0x0000 0x0000
Code area
SFR RAM
0x0FFF
0x7FFF 0x8000
0x7FFF 0x8000
32768 bytes Flash Flash
32768 bytes AREA C1
AREA C1
0xFFFF
0xFFFF
Data area If FLSCR = "10"
Code area
Figure 21-1 Area Switching Using the FLSCR1 Setting
RA003 Page 308
TMP89FM42
21.2.3 RAM area switching (SYSCR3)
If "0xD4" is set on SYSCR4 after SYSCR3 is set to "1" in MCU mode, RAM is mapped to the code area. To restore the RAM area to the initial state of mapping, set SYSCR3 to "0", and then set "0xD4" on SYSCR4. In serial PROM mode, RAM is mapped to the code area, irrespective of the SYSCR3 setting.
21.2.4 BOOTROM area switching (FLSCR1)
If "0xD5" is set on FLSCR2 after FLSCR1 is set to "1" in MCU mode, 0x1000 through 0x17FF in the code and data areas is masked by flash memory, and 2K-byte (first half of 4KB) BOOTROM is mapped. If you do not want to map BOOTROM, set "0xD5" on FLSCR2 after setting FLSCR1 to "0". A set of codes for programming flash memory in serial PROM mode are built into BOOTROM, and a support program (API) for performing an erase or write on flash memory in a simple manner is also built into one part in the BOOTROM area. Therefore, by calling a subroutine in the support program after BOOTROM is mapped, it is possible to erase, write and read flash memory easily. In serial PROM mode, BOOTROM is mapped to 0x1000 through 0x17FF in the data area and 0x1000 through 0x1FFF in the code area, irrespective of the FLSCR1 setting. BAREA is always "1", and the set BAREA value remains unchanged, even if data is written. "1" is always read from BAREA.
RA003
Page 309
21. Flash Memory
TMP89FM42
0x0000 0x003F 0x0040 0xXXXX 0x1000
0x0000
0x0000 0x003F 0x0040 0xXXXX 0x1000
0x0000
SFR RAM
SFR RAM
0x003F 0x0040 0xXXXX 0xXXXX+1
RAM
0xFFFF
0xFFFF
0xFFFF
0xFFFF
Data area
Code area If SYSSR4="0" FLSCR1="0"
Data area
Code area If SYSSR4="1" FLSCR1="0"
0x0000 0x003F 0x0040 0xXXXX 0x1000
0x0000
0x0000 0x003F 0x0040 0xXXXX
0x0000
SFR RAM
0x1000
SFR RAM
0x003F 0x0040 0xXXXX 0x1000
RAM
0x1000
BOOTROM
0x17FF 0x1800 0x17FF 0x1800
BOOTROM
0x17FF 0x1800
BOOTROM
0x17FF 0x1800
BOOTROM
0xFFFF
0xFFFF
0xFFFF
0xFFFF
Data area
Code area If SYSSR4="0" FLSCR1="1"
Data area
Code area If SYSSR4="1" FLSCR1="1"
0x0000 0x003F 0x0040 0xXXXX 0x1000
0x0000
SFR RAM
0x003F 0x0040 0xXXXX 0x1000
RAM
BOOTROM
0x17FF 0x1800 0x17FF 0x1800
BOOTROM
0xFFFF
0xFFFF
Note : XXXXH is end of RAM address.
Data area In serial PROM mode
Code area
Figure 21-2 Show/Hide Switching for BOOTROM and RAM
21.2.5 Flash memory standby control (FLSSTB)
FLSSTB is the register provided to maintain the compatibility with the previous product version. It must normally be set to "0". In using FLSSTB built into the TMP89FM42, the following point should be noted: FLSSTB can be configured only by using a program allocated to RAM. If it is configured by using a program allocated to the flash memory, the configured value will be invalidated and does not take effect. To access the flash memory again after setting FLSSTB to "1", set FLSSTB to "0" by using a program allocated to RAM. If the flash memory is accessed with FLSSTB set to "1," a flash standby reset will occur.
RA003
Page 310
TMP89FM42
If an interrupt occurs when the interrupt vector is assigned to the flash memory area (SYSCR3 = "0" is effective), FSTB is automatically initialized to "0", and then the interrupt vector of the flash memory area is read. If an interrupt occurs when the interrupt vector is assigned to the RAM area (SYSCR3 = "1" is effective), FSTB is not cleared to "0", and then the interrupt vector of the RAM area is read. In this case, the RAM area should be designated as a referential address of interrupt vector. If the flash memory area is designated as a referential address of interrupt vector, a flash standby reset occurs after an interrupt is generated.
21.2.6 Port input control register (SPCR)
In serial PROM mode, the input levels of all ports, except the ports RXD0 and TXD0 used in serial PROM mode, are physically fixed after a reset is released. This is designed to prevent a penetration current from flowing through unused ports (port inputs and functional peripheral inputs, which are also used as ports, are disabled). To access the flash memory using the RAM loader mode and a method other than the UART, therefore, port inputs must be set to "enable". To enable the SCLK0 port input, set SPCR to "1". To enable port inputs other than RXD0, TXD0 and SCLK0 port inputs, set SPCR to "1". In MCU mode, the SPCR register does not function.
RA003
Page 311
21. Flash Memory
TMP89FM42
21.3 Command Sequence
In MCU and serial PROM modes, the command sequence consists of six commands (JEDEC compatible), as shown in Table 21-1. Table 21-1 Command Sequence
1st Bus Write Cycle Add 1 Byte Program Sector Erase (partial erase in units of 4KB) Chip Erase (all erase) Product ID Entry Product ID Exit Security Program 0x#555 Data 0xAA 2nd Bus Write Cycle Add 0x#AAA Data 0x55 3rd Bus Write Cycle Add 0x#555 Data 0xA0 4th Bus Write Cycle Add BA (Note 1) Data Data (Note 1) 5th Bus Write Cycle Add Data 6th Bus Write Cycle Add Data -
Command sequence
2
0x#555
0xAA
0x#AAA
0x55
0x#555
0x80
0x#555
0xAA
0x#AAA
0x55
SA (Note 2)
0x30
3 4 5 6
0x#555 0x#555 0xXX 0x#555
0xAA 0xAA 0xF0 0xAA
0x#AAA 0x#AAA 0x#AAA
0x55 0x55 0x55
0x#555 0x#555 0x#555
0x80 0x90 0xA5
0x#555 0xFF7F
0xAA 0x00
0x#AAA -
0x55 -
0x#555 -
0x10 -
Note 1: Specify the address and data to be written (Refer to Table 21-2 about BA). Note 2: The area to be erased is specified with the upper 4 bits of the address (Refer to Table 21-3 about SA). Note 3: Do not start the STOP, IDLE0, IDLE1, IDLE2, SLEEP1 or SLEEP0 mode while a command sequence is being executed or a task specified in a command sequence is being executed (write, erase or ID entry). Note 4: # ; 0x8 through 0xF should be specified as the upper 4bits of the address. Usually, it is recommended that 0xF is specified. Note 5: XXX ; Don't care
21.3.1 Byte program
This command writes the flash memory in units of one byte. The address and data to be written are specified in the 4th bus write cycle. The range of addresses that can be specified is shown in Table 21-2. For example, to write data to 0x8000 in the data area, set FLSCR1 to "0y00", set "0xD5" on FLSCR2, and then specify 0x8000 as an address in the 4th bus write cycle. The time needed to write each byte is 40 s maximum. The next command sequence cannot be executed if an ongoing write operation is not completed. To check the completion of the write operation, perform read operations twice on the same address in the flash memory, and perform polling until the same data is read from the flash memory. During the write operation, bit 6 is reversed each time a read is performed.
Note 1: To rewrite data to addresses in the flash memory where data (including 0xFF) is already written, make sure that you erase the existing data by performing a sector erase or chip erase before writing data. Note 2: The data and code areas become mirror areas. As you access these areas, you are brought to the same physical address in memory. When performing a Byte Program, make sure that you write data to either of these two areas, not both. Note 3: Do not perform a Byte Program on areas other than those shown in Table 21-2.
Table 21-2 Range of Addresses Specifiable (BA)
Write Area AREA D1 (Data area) AREA C1 (Code area) FLSCR1 00 Address specified by instruction (Address of 4th bus write cycle) 0x8000 through 0xFFFF
0x8000 through 0xFFFF
0x8000 through 0xFFFF
10
0x8000 through 0xFFFF
RA003
Page 312
TMP89FM42
21.3.2 Sector erase (4-kbyte partial erase)
This command erases the flash memory in units of 4 kbytes. The flash memory area to be erased is specified by the upper 4 bits of the 6th bus write cycle address. The range of addresses that can be specified is shown in Table 21-3. For example, to erase 4 kbytes from 0x8000 through 0x8FFF in the code area, set FLSCR1 to "0y10", set "0xD5" on FLSCR2, and then specify either 0x8000 or 0x8FFF as the 6th bus write cycle. The sector erase command is effective only in MCU and serial PROM modes, and it cannot be used in parallel PROM mode. The time needed to erase 4 kbytes is 30 ms maximum. The next command sequence cannot be executed if an ongoing erase operation is not completed. To check the completion of the erase operation, perform read operations twice on the same address in the flash memory, and perform polling until the same data is read from the flash memory. During the erase operation, bit 6 is reversed each time a read is performed. Data in the erased area is 0xFF.
Note 1: The data and code areas become mirror areas. As you access these areas, you are brought to the same physical address in memory. When performing a sector erase, make sure that you erase data from either of these two areas, not both. Note 2: Do not perform a sector erase on areas other than those shown in Table 21-3.
Table 21-3 Range of Addresses Specifiable
Erase Area 0x8000 through 0x8FFF 0x9000 through 0x9FFF 0xA000 through 0xAFFF AREA D1 (Data area) 0xB000 through 0xBFFF 00 0xC000 through 0xCFFF 0xD000 through 0xDFFF 0xE000 through 0xEFFF 0xF000 through 0xFFFF 0x8000 through 0x8FFF 0x9000 through 0x9FFF 0xA000 through 0xAFFF AREA C1 (Code area) 0xB000 through 0xBFFF 10 0xC000 through 0xCFFF 0xD000 through 0xDFFF 0xE000 through 0xEFFF 0xF000 through 0xFFFF 0xC000 through 0xCFFF 0xD000 through 0xDFFF 0xE000 through 0xEFFF 0xF000 through 0xFFFF 0xC000 through 0xCFFF 0xD000 through 0xDFFF 0xE000 through 0xEFFF 0xF000 through 0xFFFF 0x8000 through 0x8FFF 0x9000 through 0x9FFF 0xA000 through 0xAFFF 0xB000 through 0xBFFF FLSCR1 Address specified by instruction (Address of 6th bus write cycle) 0x8000 through 0x8FFF 0x9000 through 0x9FFF 0xA000 through 0xAFFF 0xB000 through 0xBFFF
21.3.3 Chip erase (all erase)
This command erases the entire flash memory. The time needed to erase it is 30 ms maximum. The next command sequence cannot be executed if an ongoing erase operation is not completed. To check the completion of the erase operation, perform read operations twice on the same address in the flash memory, and perform polling until the same data is read from the flash memory. During the erase operation, bit 6 is reversed each time a read is performed. Data in the erased area is 0xFF.
RA003
Page 313
21. Flash Memory
21.4 Toggle Bit (D6) TMP89FM42
21.3.4 Product ID entry
This command activates the product ID mode. If an instruction to read the flash memory is executed in Product ID mode, the vendor ID, flash ID and security status can be read from the flash memory. Table 21-4 Values to Be Read in Product ID Mode
Address 0xF000 0xF001 Meaning Vendor ID Flash ID 0x98 0x4D 0xFF: 0xFF7F Security status Other than 0xFF: Security program enabled Security program disabled Read value
21.3.5 Product ID exit
This command is used to exit the Product ID mode.
21.3.6 Security program
If the security program is enabled, the flash memory is write and read protected in parallel PROM mode, and the flash memory overwrite command and the RAM loader command cannot be executed in serial PROM mode. To disable the security program, the chip erase must be performed. To check whether the security program is enabled or disabled, read 0xFF7F in product ID mode. Refer to Table 21-4 for further details. The time needed to enable or disable the security program is 40 s maximum. The next command sequence cannot be executed until the security program setting is completed. To check the completion of the security program setting, perform read operations twice on the same address in the flash memory, and perform polling until the same data is read. When the security program setting is being made, bit 6 is reversed each time a read is performed.
21.4 Toggle Bit (D6)
After the flash memory write, the chip erase, and the security program command sequence are executed, the value of the 6th bit (D6) in data read by a read operation is reversed each time a read is performed. This bit reversal can be used as a software mechanism for checking the completion of each operation. Normally, perform read operations twice on the same address in the flash memory, and perform polling until the same data is read from the flash memory. After the flash memory write, the chip erase, and the security program command sequence are executed, the toggle bit read by the first read operation is always "1".
Note 1: If FLSCR1 is set to "disable", the toggle bit is not reversed. Note 2: Do not read the toggle bit by using a 16-bit transfer instruction. If the toggle bit is read using a 16-bit transfer instruction, the toggle bit does not function properly. Note 3: Because the instruction cycle is longer than the write time in SLOW mode, the value is not reversed, even if the toggle bit is read right after the Byte Program is performed.
RA003
Page 314
TMP89FM42
21.5 Access to the Flash Memory Area
A read or a program fetch cannot be performed on the whole of the flash memory area if data is being written to the flash memory, if data in flash memory is being erased or if a security setting is being made in the flash memory. When performing these operation on the flash memory area, the flash memory cannot be directly accessed by using a program in the flash memory; the flash memory must be accessed using a program in the BOOTROM area or the RAM area. Data can be written to and read from the flash memory area in units of one byte. Data in the flash memory can be erased in units of 4 kbytes, and all data in the flash memory can be erased at one stroke. A read can be performed using one memory transfer instruction. A write or erase, however, must be performed using more than one memory transfer instruction because the command sequence method is used. For information on the command sequence, refer to Table 21-1.
Note 1: To allow a program to resume control on the flash memory area that is rewritten, it is recommended that you let the program jump (return) after verifying that the program has been written properly. Note 2: Do not reset the MCU (including a reset generated due to internal factors) when data is being written to the flash memory, data is being erased from the flash memory or the security command is being executed. If a reset occurs, there is the possibility that data in the flash memory may be rewritten to an unexpected value.
21.5.1 Flash memory control in serial PROM mode
The serial PROM mode is used to access the flash memory by using a control program provided in the BOOTROM area. Since almost all operations relating to access to the flash memory can be controlled simply using data supplied through the serial interface (UART or SIO), it is not necessary to operate the control register for the user. For details of the serial PROM mode, see "Serial PROM Mode". To access the flash memory in serial PROM mode by using a user-specific program or peripheral functions other than UART and SIO, it is necessary to execute a control program in the RAM area by using the RAM loader command of the serial PROM mode. How to execute this control program is described in "21.5.1.1 How to transfer and write a control program to the RAM area in RAM loader mode of the serial PROM mode".
21.5.1.1 How to transfer and write a control program to the RAM area in RAM loader mode of the serial PROM mode
How to execute a control program in the RAM area in serial PROM mode is described below. A control program to be executed in the RAM area must be generated in the Intel-Hex format and be transferred using the RAM loader of the serial PROM mode. Steps 1 and 2 shown below are controlled by a program in the BOOTROM, and other steps are controlled by a program transferred to the RAM area. The following procedure is linked with a program example to be explained later. 1. Transfer the write control program to the RAM area in RAM loader mode. 2. Jump to the RAM area. 3. Set a nonmaskable interrupt vector in the RAM area. 4. Set FLSCR1 to "0y101", and specify the area to be erased by making the appropriate FLSCR1 setting. (Make the appropriate FLSCR1 setting as required.) Then set "0xD5" on FLSCR2. 5. Execute the erase command sequence. 6. Read the same flash memory address twice consecutively. (Repeat step 6 until the read values become the same.) 7. Specify the area (area erased in step 5 above) to which data is written by making the appropriate FLSCR1 setting. (Make the appropriate FLSCR1 setting as required.) Then set "0xD5" on FLSCR2. 8. Execute the write command sequence. 9. Read the same flash memory address twice consecutively. (Repeat step 9 until the read values become the same.)
RA003
Page 315
21. Flash Memory
21.4 Toggle Bit (D6) TMP89FM42
10. Set FLSCR1 to "0y010", and then set "0xD5" on FLSCR2 (to disable the execution of the command sequence).
Note 1: If the RAM loader is used in serial PROM mode, the BOOTROM disables (DI) a maskable interrupt, and the interrupt vector area is designated as a RAM area (SYSCR3="1"). Considering that a nonmaskable interrupt may be generated unexpectedly, it is recommended that vector addresses corresponding these interrupts (INTUNDEF, INTSWI: 0x01F8 to 0x01F9, WDT: 0x01FC to 0x01FD) be established and that an interrupt service routine be defined inside the RAM area. Note 2: If a certain interrupt is used in the RAM loader program, a vector address corresponding to that interrupt and the interrupt service routine must be established inside the RAM area. In this case, it is recommended that a nonmaskable interrupt be handled as explained in Note 1. Note 3: Do not set SYSCR3 to "0" by using the RAM loader program. If an interrupt occurs with SYSCR3 set to "0", the BOOTROM area is referenced as a vector address and, therefore, the program will not function properly. Example: A case in which a program is transferred to RAM, the sector erase is performed on 0xE000 through 0xEFFF in the code area, and then data of 0x3F is written to 0xE500.
main section code abs = 0x0100 ; #### Set a nonmaskable interrupt vector inside the RAM area #### (step 3) LD LDW LD LDW LD LD ; Sector erase process (step 5) LD LD CALL ; Write process (step 8) LD LD LD CALL : J sSectorErase: ; Sector erase process LD LD LD LD LD LD J ; Write process sByteProgram: CALL LD LD LD LD ; End process sRAMopEnd NOP NOP NOP sLOOP1: LD CMP J LD LD RET ; Convert address (steps 4 and 7) A,(IX) A,(IX) NZ,sLOOP1 (FLSCR1),0x40 (FLSCR2),0xD5 ; Loop until the read values become the same ; Disable the execution of command sequence (step 10) ; Reflect the FLSCR1 setting ; Return to flash memory ; (note 2) ; (note 2) ; (note 2) ; (step 6,9) sAddConv (HL),E (DE),L (HL),0xA0 (IX),B ; Convert address ; 1st Bus Write Cycle (note 1) ; 2nd Bus Write Cycle (note 1) ; 3rd Bus Write Cycle (note 1) ; 4th Bus Write Cycle (note 1) (HL),E (DE),L (HL),0x80 (HL),E (DE),L (IX),0x30 sRAMopEnd ; 1st Bus Write Cycle (note 1) ; 2nd Bus Write Cycle (note 1) ; 3rd Bus Write Cycle (note 1) ; 4th Bus Write Cycle (note 1) ; 5th Bus Write Cycle (note 1) ; 6th Bus Write Cycle (note 1) CALL C,0x00 IX,0xE500 B,0x3F sByteProgram : XXXXX sAddConv ; Address conversion process ; Set upper address ; Set middle and lower addresses ; Data to be written ; Write process (0xE500) ; Execute the main program C,0x00 IX,0xE000 sSectorErase ; Set upper address ; Set middle and lower addresses ; Perform a sector erase (0xE000) HL,0x01FC (HL),sINTSWI HL,0x01F8 (HL),sINTWDT HL,0xF555 DE,0xFAAA ; Variable for command sequence ; Variable for command sequence ; Set INTWDT interrupt vector ; Set INTUNDEF and INTSWI interrupt vectors
; #### Sector erase and write process ####
; #### Execute the next main program ####
; #### Program to be executed in RAM ####
RA003
Page 316
TMP89FM42
sAddConv:
LD SWAP AND SWAP AND OR XOR SHRC OR LD LD LD TEST J OR LD
WA,IX C C,0x10 W W,0x08 C,W C,0x08 C C,0xA0 (FLSCR1),C (FLSCR2),0xD5 WA,IX C.3 Z,sAddConvEnd W,0x80 IX,WA ; Enable the execution of command sequence. Make the FAREA setting. ; Reflect the FLSCR1 setting
sAddConvEnd: ; Interrupt subroutine sINTWDT: sINTSWI:
RET
: RETN : RETN
: :
; Error processing ; Error processing
Note 1: In using a write instruction in the xxx bus write cycle, make sure that you use a write instruction of more than three machine cycles or arrange write instructions in such a way that they are generated at intervals of three or more machine cycles. If a 16-bit transfer instruction is used or if write instructions are executed at intervals of two machine cycles, the flash memory command sequence will not be transmitted properly, and a malfunction may occur. Note 2: If a read of the flash memory (toggle operation) is to be performed after a write instruction is generated in the xth bus write cycle, instructions must be arranged in such a way that they are generated at intervals of three or more machine cycles; machine cycles are counted from when the last xth bus write cycle is generated to when each instruction is generated. Three NOP instructions are normally used. If the interval between instructions is short, the toggle bit does not operation correctly.
RA003
Page 317
21. Flash Memory
21.4 Toggle Bit (D6) TMP89FM42
21.5.2 Flash memory control in MCU mode
In MCU mode, a write can be performed on the flash memory by executing a control program in RAM or using a support program (API) provided inside BOOTROM.
21.5.2.1 How to write to the flash memory by transferring a control program to the RAM area
This section describes how to execute a control program in RAM in MCU mode. A control program to be executed in RAM must be acquired and stored in the flash memory or it must be imported from an outside source through a communication pin. (The following procedure assumes that a program copy is provided inside the flash memory.) Steps 1 through 5 and 11 shown below concern the control by a program in the flash memory, and other steps concern the control by a program transferred to RAM. The following procedure is linked with a program example to be described later. 1. Set the interrupt master enable flag to "disable (DI)" (IMF "0"). 2. Transfer the write control program to RAM. 3. Establish the nonmaskable interrupt vector in the RAM area. 4. After setting both SYSCR3 and SYSCR3 to "1", set "0xD4" on FLSCR4. Then allocate RAM to the code area, and switch the vector area to the RAM area. 5. Invoke the erase processing program in the RAM area by generating a CALL instruction. 6. Set FLSCR1 to "0y101", and specify the area to be erased by making the appropriate FLSCR1 setting. (Make the appropriate FLSCR1 setting, as necessary.) Then set "0xD5" on FLSCR2. 7. Execute the erase command sequence. 8. Perform a read on the same address in the flash memory twice consecutively. (Repeat this step until the read values become the same.) 9. After setting FLSCR1 to "0y010" and FLSCR1 to "0y00", set "0xD5" on FLSCR2. (This disables the execution of the command sequence and returns FAREA to the initial state of mapping.) 10. Generate the RET instruction to return to the flash memory. 11. Invoke the write program in the RAM area by generating a CALL instruction. 12. Set FLSCR1 to "0y101", and make the appropriate FLSCR1 setting to specify the area (area erased by performing step 7 above) on which a write is to be performed. (Make the appropriate FLSCR1 setting, as necessary.) Then set "0xD5" on FLSCR2. 13. Execute the write command sequence. 14. Perform a read on the same address in the flash memory twice consecutively. (Repeat this step until the read values become the same.) 15. After setting FLSCR1 to "0y010" and FLSCR1 to "0y00", set "0xD5" on FLSCR2. (This disables the execution of the command sequence and returns FAREA to the initial state of mapping.) 16. Generate the RET instruction to return to the flash memory.
Note 1: Before writing data to the flash memory from the RAM area in MCU mode, the vector area must be switched to the RAM area by using SYSCR3, data must be written to the vector addresses (INTUNDEF, INTSWI: 0x01F8 to 0x01F9, INTWDT: 0x01FC to 0x01FD) that correspond to nonmaskable interrupts, and the interrupt subroutine (RAM area) must be defined. This allows you to trap the errors that may occur due to an unexpected nonmaskable interrupt during a write. If SYSCR3 is set in the flash memory area and if an unexpected interrupt occurs during a write, a malfunction may occur because the vector area in the flash memory cannot be read properly. Note 2: Before using a certain interrupt in MCU mode, the vector address corresponding to that interrupt and the interrupt service routine must be established inside the RAM area. In this case, the nonmaskable interrupt setting must be made, as explained in Note 1.
RA003
Page 318
TMP89FM42
Note 3: Before jumping from the flash memory to the RAM area, RAM must be allocated to the code area by making the appropriate SYSCR3 setting (setting made in step 4 in the procedure described on the previous page). Example: Case in which a program is transferred to RAM, a sector erase is performed on 0xE000 through 0xEFFF in the code area, and then 0x3F data is written to 0xE500.
cRAMStartAdd main section code abs = 0x1000 DI
equ 0x0200
; RAM start address ; Disable interrupts (step 1)
; #### Transfer the program to RAM #### (step 2) LD LD sRAMLOOP: LD LD INC INC CMP J LD LDW LD LDW LD LD LD LD ; Sector erase process (step 5) LD LD CALL ; Write process (step 11) LD LD LD CALL C,0x00 IX,0xE500 B,0x3F ; Set upper addresses ; Set middle and lower addresses ; Data to be written ; Write process (0xE500) ; #### Execute the next main program #### : J sRAMprogStart: sSectorErase: CALL sAddConv - sRAMprogStart + cRAMStartAdd ; Address conversion process ; Sector erase process (step 7) LD LD LD LD LD LD J ; Write process (step 13) sByteProgram CALL LD LD LD LD ; End process sRAMopEnd: NOP NOP NOP ; (note 2) ; (note 2) ; (note 2) sAddConv - sRAMprogStart + cRAMStartAdd ; Address conversion process (HL),E (DE),L (HL),0xA0 (IX),B ; 1st Bus Write Cycle (note 1) ; 2nd Bus Write Cycle (note 1) ; 3rd Bus Write Cycle (Note 1) ; 4th Bus Write Cycle (note 1) (HL),E (DE),L (HL),0x80 (HL),E (DE),L (IX),0x30 sRAMopEnd ; 1st Bus Write Cycle (note 1) ; 2nd Bus Write Cycle (note 1) ; 3rd Bus Write Cycle (note 1) ; 4th Bus Write Cycle (note 1) ; 5th Bus Write Cycle (note 1) ; 6th Bus Write Cycle (note 1) : XXXXX ; Execute the main program C,0x00 IX,0xE000 sRAMStartAdd ; Set upper addresses ; Set middle and lower addresses ; Perform a sector erase (0xE000) HL,cRAMStartAdd IX,sRAMprogStart A,(IX) (HL),A HL IX IX,sRAMprogEnd NZ,sRAMLOOP HL,0x01FC HL,0x01F8 ; Set INTUNDEF and INTSWI interrupt vectors ; Set INTWDT interrupt vector ; Transfer the program from sRAMprogStart to ; sRAMprogEnd to cRAMStartAdd.
; #### Set a nonmaskable interrupt vector inside the RAM area #### (step 3) (HL),sINTSWI - sRAMprogStart + cRAMStartAdd (HL),sINTWDT - sRAMprogStart + cRAMStartAdd (SYSCR3),0x06 (SYSCR4),0xD4 HL,0xF555 DE,0xFAAA ; Set RAREA and RVCTR to "1" ; Enable Code ; Variable for command sequence ; Variable for command sequence
; #### Allocate RAM to the code area. Switch the vector area to RAM #### (step 4)
; #### Sector erase and write process ####
sByteProgram - sRAMprogStart + cRAMStartAdd
; #### Program to be executed in RAM ####
RA003
Page 319
21. Flash Memory
21.4 Toggle Bit (D6) TMP89FM42
sLOOP1:
LD CMP J LD LD RET
A,(IX) A,(IX) NZ,sLOOP1 (FLSCR1),0x40 (FLSCR2),0xD5
; (steps 8,14) ; Loop until the read values become the same ; Disable the execution of command sequence (steps 9 and 15) ; Reflect the FLSCR1 setting ; Return to flash memory
; Address conversion process (steps 6 and 12) sAddConv: LD SWAP AND SWAP AND OR XOR SHRC OR LD LD LD TEST J OR LD sAddConvEnd: sINTWDT: sINTSWI: sRAMprogEnd: RET : RETN : RETN NOP : ; Error processing : ; Error processing ; Interrupt subroutine WA,IX C C,0x10 W W,0x08 C,W C,0x08 C C,0xA0 (FLSCR1),C (FLSCR2),0xD5 WA,IX C.3 Z,sAddConvEnd W,0x80 IX,WA ; Enable the execution of command sequence. Make the FAREA setting. ; Reflect the FLSCR1 setting
Note 1: In using a write instruction in the xxx bus write cycle, make sure that you use a write instruction of more than three machine cycles or arrange write instructions in such a way that they are generated at intervals of three or more machine cycles. If a 16-bit transfer instruction is used or if write instructions are executed at intervals of two machine cycles, the flash memory command sequence will not be transmitted properly, and a malfunction may occur. Note 2: If a read of the flash memory (toggle operation) is to be performed after a write instruction is generated in the xth bus write cycle, instructions must be arranged in such a way that they are generated at intervals of three or more machine cycles; machine cycles are counted from when the last xth bus write cycle is generated to when each instruction is generated. Three NOP instructions are normally used. If the interval between instructions is short, the toggle bit does not operation correctly. Example: Case in which data is read from 0xF000 in the code area and stored at 0x98 in RAM
LD LD LD LD LD LD
(FLSCR1),0xA8 (FLSCR2),0xD5 A,(0xF000) (0x98),A (FLSCR1),0x40 (FLSCR2),0xD5
; Select AREA C1 ; Reflect the FLSCR1 setting ; Read data from 0xF000 ; Store data at 0x98 ; Select AREA D0 ; Reflect the FLSCR1 setting
RA003
Page 320
TMP89FM42
21.5.2.2 How to write to the flash memory by using a support program (API) of BOOTROM
This section describes how to perform an erase and a write on the flash memory by using a support program (API) of BOOTROM in MCU mode.
Example: Case in which a sector erase is performed on 0xE000 through 0xEFFF in the data area, and then data at 0x0100 through 0x01FF is written to 0xE000 through 0xE0FF in the data area.
.BTWrite .BTEraseSec .BTGetRP .BTSetRP main section code abs = 0xF000 ; Initial setting LD LD ; Sector erase process (API) LD LD CALL ; Write process LD LD sLOOP1: LD LD LD LD CALL INC INC CMP J ; End process LD LD
equ 0x1010 equ 0x1012 equ 0x1016 equ 0x1018
; Write data to the flash memory ; Sector Erase ; Chip Erase ; Check the status of the security program ; Configure the security program
.BTEraseChip equ 0x1014
(FLSCR1),0x50 (FLSCR2),0xD5 A,0x0E C,0xD5 (.BTEraseSec) HL,0xE000 IY,0x0100 C,0x00 WA,HL E,(IY) (SP-),0xD5 (.BTWrite) IY HL L,0x00 NZ,sLOOP1 (FLSCR1),0x40 (FLSCR2),0xD5
; Set BAREA to "1" (note) ; Reflect the FLSCR1 setting ; Specify the area to be erased (0xE000 through 0xEFFF) ; Enable Code ; Execute sector erase ; Flash start address (address where data is written) ; RAM start address ; Address where data is written (bit 16) ; Address where data is written (bits 15 to 0) ; Data to be written ; Enable Code ; Write data to the flash memory (1 byte) ; Increment flash address ; Increment RAM address ; Finish 256-byte write? ; Return to sLOOP1 if the number of bytes is less than 256 ; Set BAREA to "0"
Example: Whether the security program is enabled or disabled is checked. If it is disabled, it is enabled.
.BTWrite .BTEraseSec .BTGetRP .BTSetRP main section code abs = 0xF000 ; Initial setting LD LD LD LD CALL CMP J LD LD CALL sSKIP LD
equ 0x1010 equ 0x1012 equ 0x1016 equ 0x1018
; Write data to the flash memory ; Sector Erase ; Chip Erase ; Check the status of the security program ; Enable the security program
.BTEraseChip equ 0x1014
(FLSCR1),0x50 (FLSCR2),0xD5 A,0xD5 C,0x00 (.BTGetRP) A,0xFF NZ,sSKIP A,0xD5 C,0x00 (.BTSetRP) (FLSCR1),0x40
; Set BAREA to "1" ; Reflect the FLSCR1 setting ; Enable Code ; Set 0x00 (note 1) ; Check the status of the security program ; Go to sSKIP if the security program is enabled ; Enable Code ; Set 0x00 (note 1) ; Enable the security program ; Set BAREA to "0"
; Check the status of the security program
; Security program enable process (API)
RA003
Page 321
21. Flash Memory
21.4 Toggle Bit (D6) TMP89FM42
LD :
(FLSCR2),0xD5 :
Note 1: Make sure that you set the C register to "0x00".
RA003
Page 322
TMP89FM42
21.6 Revision History
Rev RA003
Description "Figure 21-2 Show/Hide Switching for BOOTROM and RAM" Revised from WDTCR1 to SYSSR4
RA003
Page 323
21. Flash Memory
21.4 Toggle Bit (D6) TMP89FM42
RA003
Page 324
TMP89FM42
22. Serial PROM Mode
22.1 Outline
The TMP89FM42 has a 4K-byte BOOTROM (Mask ROM) for programming to flash memory. BOOTROM is available in serial PROM mode. The serial PROM mode is controlled by RXD0/SI0 pins, TXD0/SO0 pins, MODE pin, and RESET pin. In serial PROM mode, communication is performed via the UART or SIO. Table 22-1 Operating Range in Serial PROM Mode
Parameter Power supply voltage High frequency Min 4.5 1 Max 5.5 10 Unit V MHz
22.2 Security
In serial PROM mode, two security functions are provided to prevent illegal memory access attempts by a third party: password and security program functions. For more security-related information, refer to "22.12 Security".
RA002
Page 325
22. Serial PROM Mode
22.3 Serial PROM Mode Setting TMP89FM42
22.3 Serial PROM Mode Setting
22.3.1 Serial PROM mode control pins
To execute on-board programming, activate the serial PROM mode. Table 22-2 shows the pin setting used to activate the serial PROM mode. Table 22-2 Serial PROM Mode Setting
Pin RXD0 / SI0 / P21 pin TXD0 / SO0 / P20 pin MODE, RESET pin Setting H level H level
Note: Before you activate the serial PROM mode, you must set the RXD0/SI0/P21 and TXD0/SO0/P20 pins to high (H) level by using a pull-up resistor.
Table 22-3 Pin Functions in Serial PROM Mode
Pin name (in serial PROM mode) TXD0 / SO0 RXD0 / SI0
RESET
Input/output Output Input Input Input
Function Serial PROM mode control/serial data output Serial PROM mode control/serial data input Serial PROM mode control Serial PROM mode control Serial clock input (if SIO is used) These ports are in the high-impedance state in the serial PROM mode. If the UART is used, the port input is physically fixed to a specified input level in order to prevent a penetration current. To enable the port input, the SPCR must be set to "1" by operating the RAM loader control program. 4.5 V to 5.5 V (See note 1)
Pin name (in MCU mode) TXD0 / SO0 / P20 RXD0 / SI0 / P21
RESET
MODE
MODE
SCLK0
Input
SCLK0
VDD
Power supply Power supply Power supply
VAREF / AVDD
Connect to VDD.
VSS
0V These ports are in the high-impedance state in the serial PROM mode. The port input is physically fixed to a specified input level in order to prevent a penetration current (the port input is disabled). To enable the port input, the SPCR must be set to "1" by operating the RAM loader control program.
Input/output port other than RXD0 and TXD0
Input/output
XIN XOUT
Input Connect a resonator to make these pins self-oscillate. Output
Note 1: If other parts are mounted on a user board, they may interfere with data being communicated through these communication pins during on-board programming. It is recommended that these parts be somehow isolated to prevent the pins from being affected.
RA002
Page 326
TMP89FM42
TMP89FM42
VDD XIN SCLK0 RXD0 (P21) XOUT VSS GND TXD0 (P20) RESET MODE
VDD (4.5 V to 5.5 V)
Pull-up resistors
External control
Figure 22-1 Serial PROM Mode Pin Setting
Note 1: In the case of access using the UART, the control of the SCLK0 pin is unnecessary. Note 2: For information on other pin settings, refer to "Table 22-3 Pin Functions in Serial PROM Mode".
RA002
Page 327
22. Serial PROM Mode
22.4 Example Connection for On-board Writing TMP89FM42
22.4 Example Connection for On-board Writing
Figure 22-2 shows example connections to perform on-board writing.
VDD (4.5 V to 5.5 V) VDD Pull-up resistors RXD0 (P21) TXD0 (P20) (Note 2) Level converter
PC control
TMP89FM42
Other parts (Note 1)
RESET control
RESET MODE XIN XOUT VSS Serial PROM mode MCU mode
RC power-on reset circuit
GND
Target board
External control board
If UART is used
VDD (4.5 V to 5.5 V) VDD Pull-up resistors SI0 (P21) SO0 (P20) SCLK0 (P22)
Microcomputer, etc.
(Note 2)
TMP89FM42
Other parts (Note 1)
RESET control
RESET MODE XIN XOUT VSS Serial PROM mode MCU mode
RC power-on reset circuit
GND
Target board
External control board
If SIO is used
Figure 22-2 Example Connections for On-board Writing
Note 1: If other parts on a target board interfere with the UART communication in serial PROM mode, disconnect these pins by using a jumper or switch. Note 2: If the reset control circuit on a target board interferes with the startup of serial PROM mode, disconnect the circuit by using a jumper, etc. Note 3: For information on other pin settings, refer to "Table 22-3 Pin Functions in Serial PROM Mode".
RA002
Page 328
TMP89FM42
22.5 Activating the Serial PROM Mode
Activate the serial PROM mode by performing the following procedure. For information on the detailed timing, refer to "22.14.1 Reset timing". 1. Supply power to the VDD pin. 2. Set the RESET and MODE pins to low. 3. Set the RXD0/SI0/P21 and TXD0/SO0/P20 pins to high. 4. Wait until the power supply and clock oscillation stabilize. 5. Set the RESET and MODE pins from low to high. 6. Input the matching data 0x86 or 0x30 to the RXD0/SI0/P21 pins after the setup period has elapsed.
RA002
Page 329
22. Serial PROM Mode
22.6 Interface Specifications TMP89FM42
22.6 Interface Specifications
The serial PROM mode supports two communication methods: UART and SIO. The communication method is selected based on the first serial data value received after a reset. To execute an on-board program, the communication format of the external controller (personal computer, microcontroller, etc.) must be set as described below.
22.6.1 SIO communication
- Transfer rate: 250 kbps (Max.) - Data length: 8 bits - Slave (external clock) - Hardware flow control (SO0 pin) If the TMP89FM42 receives serial data "0x30" after a reset, it starts the SIO communication. In the SIO communication, the TMP89FM42 functions as a slave device. Therefore, the external controller must supply the TMP89FM42 with a serial clock (SCLK0 pin) for synchronization. If the TMP89FM42 is not outputting serial data, it controls the hardware flow by using the SO0 pin. If internal data processing is not completed yet, though data has been received, the SO0 pin outputs the L level. If internal data processing has progressed to a near-completion state or if it has been completed, the SO0 pin outputs the H level. The external controller must check the status of the SO0 pin before it starts to supply a serial clock. For information on the communication timings of each operation command, refer to " 1.11 AC Characteristics (SIO) ".
22.6.2 UART communication
- Baud rate: 9600 to 128000 bps (automatic detection) - Data length: 8 bits (LSB first) - Parity bit: None - STOP bit: 1 bit If the TMP89FM42 receives serial data "0x86" after a reset, it starts the UART communication. It also measures the pulse width of the received data (0x86), and automatically establishes the reference baud rate. In all subsequent data communication transactions, this reference baud rate is used. For information on the communication timings of each operation command, refer to "22.14 AC Characteristics (UART)". Usable baud rates differ depending on the operating frequency and are shown in Table 22-4. However, there is the possibility of data communication not working properly, even if a baud rate shown in Table 22-4 is used, because data communication is affected by frequency errors of a resonator of the external controller (personal computer, etc.), the load capacity of a communication pin, and various other factors.
RA002
Page 330
TMP89FM42
Table 22-4 Usable Baud Rates as a General Guideline
9600 bps 10 MHz 8 MHz 7.3728 MHz 6.144 MHz 6 MHz 5 MHz 4.9152 MHz 4.19 MHz 4 MHz 2 MHz 1 MHz 19200 bps 38400 bps 57600bps 115200 bps 128000 bps -
Note 1: "" means a usable baud rate. "-" means an unusable baud rate.
RA002
Page 331
22. Serial PROM Mode
22.7 Memory Mapping TMP89FM42
22.7 Memory Mapping
Figure 22-3 shows memory maps in serial PROM and MCU modes. In serial PROM mode, the BOOTROM (mask ROM) is mapped to the 0x1000 through 0x17FF in the data area and 0x1000 through 0x1FFF in the code area respectively. To write data to or erase data from flash memory by using the RAM loader command (hereafter called the 0x60 command) and an original program, data write or erase operations must be performed while switching between areas by using the flash memory control registers (FLSCR1 and 2). For information on how to specify addresses, refer to Flash Memory. When the command to write data to flash memory (hereafter called the 0x30 command) or the command to erase data from flash memory (hereafter called the 0xF0 command) is executed, BOOTROM automatically converts addresses. Therefore, as the address of flash memory, specify an address equivalent to that specified in MCU mode (if FLSCR1="0"), namely, 0x8000 through 0xFFFF.
0x0000 0x003F 0x0040 SFR RAM 0x0000 0x0000 0x003F 0x0040 0x1000 0x17FF SFR RAM BOOTROM (2048 bytes 0x1000 0x17FF BOOTROM (2048 bytes 0x0000
0x8000
0x8000
0x8000
0x8000
FLASH
FLASH
FLASH
FLASH
0xFFFF
0xFFFF
0xFFFF
0xFFFF
Data area
Code area
Data area
Code area
If FLSCR1="0" (MCU mode)
0x0000 0x003F 0x0040 0x1000 0x17FF
If FLSCR1="1" (MCU mode)
0x0000 SFR RAM BOOTROM (2048 bytes 0x1000 BOOTROM (4096 bytes 0x1FFF 0x8000 0x8000
FLASH
FLASH
0xFFFF
0xFFFF
Data area If serial PROM mode
Code area
Figure 22-3 Memory Mapping
22.8 Operation Commands
In serial PROM mode, the commands shown in Table 22-5 are used. After a reset is released, the TMP89FM42 goes into a standby state and awaits the arrival of matching data 1 (0x86 or 0x30).
RA002
Page 332
TMP89FM42
Table 22-5 Operation Command in Serial PROM Mode
Command data Operation command Description After a reset is released, the serial PROM mode always starts operation with this command. If matching data 1 is 0x86, communication starts in the UART format. If matching data 1 is 0x30, communication starts in the SIO format. Data in the flash memory area (address 0x8000 through 0xFFFF) can be erased. Data can be written to the flash memory area (address 0x8000 through 0xFFFF). Data can be read from the flash memory area (address 0x8000 through 0xFFFF). Data can be written to a specified RAM area (address 0x0060 through 0x083F). 0xFF check data and 2-byte checksums of the entire flash memory area (address 0x8000 through 0xFFFF) are output in descending order (from upper to lower bytes). Product ID codes are output. The security program status and other status codes are output. Flash products of 124K or 96Kbytes can be provisioned to emulate a smallcapacity mask ROM product. The security program setting is enabled.
0x86 or 0x30
Setup (matching data 1, 2)
0xF0 0x30 0x40 0x60
Flash memory erase Flash memory write Flash memory read RAM loader
0x90
Flash memory SUM output
0xC0 0xC3 0xD0 0xFA
Product ID code output Flash memory status output Mask ROM emulation setting Flash memory security setting
Each command is outlined below. For detailed information on how each command works, refer to 22.8.1 and subsequent sections. 1. Flash memory erase command Either Chip Erase (total erase of flash memory) or Sector Erase (erase of flash memory in 4K-byte units) can be used to erase the data in flash memory. Data in the erased area is 0xFF. If the security program is enabled or if the option code EPFC_OP is 0xFF, the flash erase command of Sector Erase cannot be executed. To disable the security program setting, execute the flash erase command of Chip Erase. Before erasing the data in flash memory, the TMP89FM42 performs password authentication except where a product is a blank product or EPFC_OP is 0xFF. If a password is not authenticated, the flash memory erase command is not executed. 2. Flash memory write command Data can be written in single-byte units to a specified address in flash memory. Provision the external controller so that it transmits data to write as binary data in the Intel Hex format. If errors do not occur until the end record is reached, the TMP89FM42 calculates checksums in the entire flash memory area (0x8000 through 0xFFFF), and returns the calculation results. If the security program is enabled, the flash memory write command cannot be executed. In this case, execute Chip Erase beforehand by using the flash memory erase command. Before executing the flash memory write command, the TMP89FM42 performs password authentication except where a product is a blank product. If a password is not authenticated, the flash memory write command is not executed. 3. Flash memory read command Data can be read from a specified address in flash memory in single-byte units. Provision the external controller so that it transmits the address in memory where a read starts, as well as the number of bytes. After outputting the number of data equal to the number of bytes, the TMP89FM42 calculates the checksums of the output data, and returns the calculation results. If the security program is enabled, the flash memory read command cannot be executed. In this case, execute Chip Erase beforehand by using the flash memory erase command. Before executing the flash memory read command, the TMP89FM42 performs password authentication except where a product is blank. If a password is not authenticated, the flash memory read command is not executed. RA002 Page 333
22. Serial PROM Mode
22.8 Operation Commands TMP89FM42
4. RAM loader command The RAM loader transfers the Intel Hex format data sent by the external controller to the built-in RAM. If it completes the data transfer normally, it calculates the checksums, transmits the calculation results, jumps to the RAM address specified by the first data record, and starts to execute the user program. If the security program is enabled, the RAM loader command is not executed. In this case, execute Chip Erase beforehand by using the flash memory erase command. Before executing the RAM loader command, the TMP89FM42 performs password authentication except where a product is blank. If a password is not authenticated, the RAM loader command is not executed. 5. Flash memory SUM output command Checksums in the entire flash memory area (0x8000 through 0xFFFF) are calculated, and the calculation results are returned. 6. Product ID code output code This is a code output used to identify a product. The output code consists of information on the ROM area and on the RAM area respectively. The external controller reads this code to identify the product to which data is to be written. 7. Flash memory status output code The status of 0xFFE0 through 0xFFFF and that of the security program are output. The external controller reads this code to identify the status of flash memory. 8. Mask ROM emulation setting command This command is nonfunctional in the TMP89FM42. It becomes functional if used for a product with flash memory of more than 96Kbytes. 9. Flash memory security setting command This command is used to prohibit the reading or writing of data in flash memory in parallel mode. In serial PROM mode, the flash memory write command and RAM loader command are prohibited. To disable the flash memory security program, execute Chip Erase by using the flash memory erase command.
RA002
Page 334
TMP89FM42
22.8.1 Flash memory erase command (0xF0)
Table 22-6 shows the flash memory erase commands. Table 22-6 Flash Memory Erase Commands
Transfer byte 1st byte 2nd byte Transfer data from the external controller to TMP89FM42 Matching data 1 (0x86 or 0x30) Baud rate Automatic adjustment Baud rate after adjustment Transfer data from TMP89FM42 to the external controller - (Automatic baud rate adjustment) OK: Echo back data (0x86 or 0x30) Error: No data transmitted OK: Echo back data (0x79 or 0xCF) Error: No data transmitted OK: Echo back data (0xF0) Error: 0xA1 x 3, 0xA3 x 3, 0x63 x 3 (note 1) OK: No data transmitted Error: No data transmitted OK: No data transmitted Error: No data transmitted OK: No data transmitted Error: No data transmitted OK: No data transmitted Error: No data transmitted OK: No data transmitted Error: No data transmitted OK: No data transmitted Error: No data transmitted OK: No data transmitted Error: No data transmitted OK: Checksum (upper byte) (note 3) Error: No data transmitted OK: Checksum (lower byte) (note 3) Error: No data transmitted -
3rd byte 4th byte
Matching data 2 (0x79 or 0xCF) -
Baud rate after adjustment Baud rate after adjustment
5th byte 6th byte
Operation command data (0xF0) -
Baud rate after adjustment Baud rate after adjustment
7th byte 8th byte
Password count storage address bit 23 to 16
Baud rate after adjustment Baud rate after adjustment Baud rate after adjustment Baud rate after adjustment
9th byte 10th byte
Password count storage address bit 15 to 08
11th byte 12th byte
Password count storage address bit 07 to 00
Baud rate after adjustment Baud rate after adjustment
BOOT ROM
13th byte 14th byte
Password comparison start address bit 23 to 16
Baud rate after adjustment Baud rate after adjustment
15th byte 16th byte
Password comparison start address bit 15 to 08
Baud rate after adjustment Baud rate after adjustment
17th byte 18th byte
Password comparison start address bit 07 to 00
Baud rate after adjustment Baud rate after adjustment
19th byte : m-th byte
Password string -
Baud rate after adjustment Baud rate after adjustment
n-th - 2 byte n-th - 1 byte
Erase area specification -
Baud rate after adjustment Baud rate after adjustment
n-th byte
-
Baud rate after adjustment
n-th + 1 byte
(Wait for the next operation command data)
Baud rate after adjustment
Note 1: "0x** x 3" means that the device goes into an idle state after transmitting 3 bytes of 0x**. Note 2: For information on the erase area specification, refer to "22.8.1.1 Specifying the erase area". For information on checksums, refer to "22.10 Checksum (SUM)". For information on passwords, refer to "22.12.1 Passwords". Note 3: Do not transmit a password string if 0xFFFA of a flash memory is 0xFF, or blank product. (However, the password count storage address and the password comparison start address must be transmitted.) Note 4: If a value less than 0x20 is transmitted at the n-th - 2 byte (execution of Sector Erase) and if 0xFFFA of flash memory is 0xFF, the TMP89FM42 goes into an idle state. Note 5: When a password error occurs, the TMP89FM42 stops communication and goes into an idle state. Therefore, when a password error occurs, initialize the TMP89FM42 by using the RESET pin, and restart the serial PROM mode. Note 6: If a communication error occurs during the transfer of a password address or a password string, the TMP89FM42 stops communication and goes into an idle state. Therefore, when a password error occurs, initialize the TMP89FM42 by using the RESET pin, and restart the serial PROM mode.
RA002
Page 335
22. Serial PROM Mode
22.8 Operation Commands TMP89FM42
22.8.1.1 Specifying the erase area
The flash memory erase command is used to specify an area in flash memory to be erased at n-th-2 byte; specifically, ERASEC is used to specify the address of an area to be erased. If data of less than 0x20 is specified, Sector Erase (erasing flash memory in 4K-byte units) is executed.. Executing Sector Erase with 0xFFFA memory set to "0xFF" or with the security program enabled will cause the device to go into an infinite loop state. If data of more than 0x20 is specified, Chip Erase (total erasure of flash memory) is executed, and the security program in flash memory is disabled. Therefore, to disable the security program in flash memory, execute Chip Erase, not Sector Erase. Erase area specification data (data at n-th-2 bytes)
7 6 5 4 ERASEC 3 2 1 0
0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F ERASEC Erase area start address 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1A 0x1B 0x1C 0x1D 0x1E 0x1F 0x20 or more
Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved 0x8000 - 0x8FFF 0x9000 - 0x9FFF 0xA000 - 0xAFFF 0xB000 - 0xBFFF 0xC000 - 0xCFFF 0xD000 - 0xDFFF 0xE000 - 0xEFFF 0xF000 - 0xFFFF Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Chip Erase (erasure of the entire area)
RA002
Page 336
TMP89FM42
Note 1: If Sector Erase is performed on an area where flash memory does not exist, the TMP89FM42 stops communication, and goes into an idle state. Note 2: If Reserved data is transmitted, the TMP89FM42 stops communication, and goes into an idle state.
RA002
Page 337
22. Serial PROM Mode
22.8 Operation Commands TMP89FM42
22.8.2 Flash memory write command (operation command: 0x30)
Table 22-7 shows the transfer formats of flash memory write commands. Table 22-7 Transfer Formats of Flash Memory Write Commands
Transfer byte 1st byte 2nd byte Transfer data from the external controller to TMP89FM42 Matching data 1 (0x86 or 0x30) Baud rate Automatic adjustment Baud rate after adjustment Transfer data from TMP89FM42 to the external controller - (Automatic baud rate adjustment) OK: Echo back data (0x86 or 0x30) Error: No data transmitted OK: Echo back data (0x79 or 0xCF) Error: No data transmitted OK: Echo back data (0x30) Error: 0xA1 x 3, 0xA3 x 3, 0x63 x 3 (note 1) OK: No data transmitted Error: No data transmitted OK: No data transmitted Error: No data transmitted OK: No data transmitted Error: No data transmitted OK: No data transmitted Error: No data transmitted OK: No data transmitted Error: No data transmitted OK: No data transmitted Error: No data transmitted OK: No data transmitted Error: No data transmitted Baud rate after adjustment OK: 0x55 Overwrite detect: 0xAA OK: Checksum (high) (note 3) Error: No data transmitted OK: Checksum (low) (note 3) Error: No data transmitted -
3rd byte 4th byte
Matching data 2 (0x79 or 0xCF) -
Baud rate after adjustment Baud rate after adjustment
5th byte 6th byte
Operation command data (0x30) -
Baud rate after adjustment Baud rate after adjustment
7th byte 8th byte
Password count storage address 23 to 16
Baud rate after adjustment Baud rate after adjustment
9th byte 10th byte
Password count storage address 15 to 08
Baud rate after adjustment Baud rate after adjustment
11th byte 12th byte
Password count storage address 07 to 00
Baud rate after adjustment Baud rate after adjustment
13th byte 14th byte BOOT ROM
Password comparison start address 23 to 16
Baud rate after adjustment Baud rate after adjustment
15th byte 16th byte
Password comparison start address 15 to 08
Baud rate after adjustment Baud rate after adjustment
17th byte 18th byte
Password comparison start address 07 to 00
Baud rate after adjustment Baud rate after adjustment
19th byte : m-th byte
Password string (note) -
Baud rate after adjustment Baud rate after adjustment
m-th+1 byte : n-th-3 byte n-th-2 byte
Intel Hex format (binary)
Baud rate after adjustment
n-th-1 byte
-
Baud rate after adjustment
n-th byte
-
Baud rate after adjustment
n-th+1 byte
(Wait for the next operation command data)
Baud rate after adjustment
Note 1: "0x** x 3" means that the device goes into an idle state after transmitting 3 bytes of 0x**. For further information, refer to Table 22-18. Note 2: For information on the Intel Hex format, refer to "22.11 Intel Hex Format (Binary)". For information on checksums, refer to "22.10 Checksum (SUM)". For information on passwords, refer to "22.12.1 Passwords". Note 3: If the area 0xFFE0 through 0xFFFF is all 0xFF, password authentication is not performed and, therefore, the password string need not be transmitted. The password count storage address and password comparison start address, however, must be specified, even for a blank product. If the password count storage address and/or password comparison start address is/are incorrect, a password error occurs, the TMP89FM42 stops communication, and it goes into an idle state.
RA002
Page 338
TMP89FM42
Therefore, if a password error occurs, initialize the TMP89FM42 by using the RESET pin, and restart the serial PROM mode. Note 4: If the security program is enabled in flash memory or if a password error occurs, the TMP89FM42 stops communication, and goes into an idle state. Therefore, if a password error occurs, initialize the TMP89FM42 by using the RESET pin, and restart the serial PROM mode. Note 5: If a communication error occurs during the transfer of a password address or a password string, the TMP89FM42 stops communication and goes into an idle state. Therefore, when a password error occurs, initialize the TMP89FM42 by using the RESET pin, and restart the serial PROM mode. Note 6: If all data in flash memory are the same data, make sure that you never write data to the address 0xFFE0 through 0xFFFF. If data is written to this address, a password error occurs, and the subsequent operations cannot be performed. Note 7: The n-th-2 byte is a flag for detecting an overwrite. If memory contents at an address where data is to be written are other than 0xFF, the n-th-2 byte is 0xAA (data is not written to this address, and the data write routine is skipped). The checksum at the n-th-1 byte or n-th byte is calculated based on data in which data in memory areas where data was not written are included. Therefore, if an overwrite is detected, the checksum of transmitted data does not match that at the n-th-1 byte or n-th byte.
RA002
Page 339
22. Serial PROM Mode
22.8 Operation Commands TMP89FM42
22.8.3 Flash memory read command (operation command: 0x40)
Table 22-8 shows the transfer formats of the flash memory read command. Table 22-8 Transfer Formats of the Flash Memory Read Command
Transfer byte 1st byte 2nd byte Transfer data from the external controller to TMP89FM42 Matching data 1 (0x86 or 0x30) Baud rate Automatic adjustment Baud rate after adjustment Transfer data from TMP89FM42 to the external controller - (Automatic baud rate adjustment) OK: Echo back data (0x86 or 0x30) Error: No data transmitted OK: Echo back data (0x79 or 0xCF) Error: No data transmitted OK: Echo back data (0x40) Error: 0xA1 x 3, 0xA3 x 3, 0x63 x 3 (note 1) OK: No data transmitted Error: No data transmitted OK: No data transmitted Error: No data transmitted OK: No data transmitted Error: No data transmitted OK: No data transmitted Error: No data transmitted OK: No data transmitted Error: No data transmitted OK: No data transmitted Error: No data transmitted OK: No data transmitted Error: No data transmitted OK: No data transmitted Error: No data transmitted OK: No data transmitted Error: No data transmitted OK: No data transmitted Error: No data transmitted OK: No data transmitted Error: No data transmitted OK: No data transmitted Error: No data transmitted OK: No data transmitted Error: No data transmitted
3rd byte 4th byte
Matching data 2 (0x79 or 0xCF) -
Baud rate after adjustment Baud rate after adjustment
5th byte 6th byte
Operation command data (0x40) -
Baud rate after adjustment Baud rate after adjustment
7th byte 8th byte
Password count storage address 23 to 16
Baud rate after adjustment Baud rate after adjustment
9th byte 10th byte
Password count storage address 15 to 08
Baud rate after adjustment Baud rate after adjustment
11th byte 12th byte
Password count storage address 07 to 00
Baud rate after adjustment Baud rate after adjustment
13th byte 14th byte
Password comparison start address 23 to 16
Baud rate after adjustment Baud rate after adjustment
15th byte 16th byte BOOT ROM
Password comparison start address 15 to 08
Baud rate after adjustment Baud rate after adjustment
17th byte 18th byte
Password comparison start address 07 to 00
Baud rate after adjustment Baud rate after adjustment
19th byte : m-th byte
Password string -
Baud rate after adjustment Baud rate after adjustment
m-th + 1 byte m-th + 2 byte
Read start address 23 to 16
Baud rate after adjustment Baud rate after adjustment
m-th + 3 byte m-th + 4 byte
Read start address 15 to 08
Baud rate after adjustment Baud rate after adjustment
m-th + 5 byte m-th + 6 byte
Read start address 07 to 00
Baud rate after adjustment Baud rate after adjustment
m-th + 7 byte m-th + 8 byte
Number of bytes to read 23 to 16
Baud rate after adjustment Baud rate after adjustment
m-th + 9 byte m-th + 10 byte
Number of bytes to read 15 to 08
Baud rate after adjustment Baud rate after adjustment
m-th + 11 byte m-th + 12 byte
Number of bytes to read 07 to 00
Baud rate after adjustment Baud rate after adjustment
RA002
Page 340
TMP89FM42
Table 22-9 Transfer Formats of the Flash Memory Read Command
Transfer byte m-th + 13 byte : n-th - 2 byte BOOT ROM n-th - 1 byte Transfer data from the external controller to TMP89FM42 Baud rate Baud rate after adjustment Baud rate after adjustment Baud rate after adjustment Transfer data from TMP89FM42 to the external controller Memory data Memory data OK: Checksum (high) Error: No data transmitted OK: Checksum (low) Error: No data transmitted -
n-th byte
-
Baud rate after adjustment
n-th + 1 byte
(Wait for the next operation command data)
Baud rate after adjustment
Note 1: "0x** x 3" means that the device goes into an idle state after transmitting 3 bytes of 0x**. For further information, refer to Table 22-18. Note 2: For information on checksums, refer to "22.10 Checksum (SUM)". For information on passwords, refer to "22.12.1 Passwords". Note 3: If the area 0xFFE0 through 0xFFFF is all 0xFF, password authentication is not performed and, therefore, the password string need not be transmitted. The password count storage address and password comparison start address, however, must be specified, even for a blank product. If the password count storage address and/or password comparison start address are/is incorrect, a password error occurs; the TMP89FM42 stops communication and goes into an idle state. Therefore, if a password error occurs, initialize the TMP89FM42 by using the RESET pin, and restart the serial PROM mode. Note 4: If the security program is enabled in flash memory or if a password error occurs, the TMP89FM42 stops communication, and goes into an idle state. Therefore, if a password error occurs, initialize the TMP89FM42 by using the RESET pin, and restart the serial PROM mode. Note 5: If a communication error occurs during the transfer of a password address or a password string, the TMP89FM42 stops communication and goes into an idle state. Therefore, when a password error occurs, initialize the TMP89FM42 by using the RESET pin, and restart the serial PROM mode. Note 6: If the number of bytes received at the m-th + 7 byte, m-th + 9 byte or m-th + 11 byte is more than 0x000000 or the size of internal memory, the TMP89FM42 stops communication and goes into an idle state.
RA002
Page 341
22. Serial PROM Mode
22.8 Operation Commands TMP89FM42
22.8.4 RAM loader command (operation command: 0x60)
Table 22-10 shows the transfer formats of the RAM loader command. Table 22-10 Transfer Formats of the RAM Loader Command
Transfer byte 1st byte 2nd byte Transfer data from the external controller to TMP89FM42 Matching data 1 (0x86 or 0x30) Baud rate Automatic adjustment Baud rate after adjustment Transfer data from TMP89FM42 to the external controller - (Automatic baud rate adjustment) OK: Echo back data (0x86 or 0x30) Error: No data transmitted OK: Echo back data (0x79 or 0xCF) Error: No data transmitted OK: Echo back data (0x60) Error: 0xA1 x 3, 0xA3 x 3, 0x63 x 3 (note 1) OK: No data transmitted Error: No data transmitted OK: No data transmitted Error: No data transmitted OK: No data transmitted Error: No data transmitted OK: No data transmitted Error: No data transmitted OK: No data transmitted Error: No data transmitted OK: No data transmitted Error: No data transmitted OK: No data transmitted Error: No data transmitted OK: Checksum (high) (note 3) Error: No data transmitted OK: Checksum (low) (note 3) Error: No data transmitted
3rd byte 4th byte
Matching data 2 (0x79 or 0xCF) -
Baud rate after adjustment Baud rate after adjustment
5th byte 6th byte
Operation command data (0x60) -
Baud rate after adjustment Baud rate after adjustment
7th byte 8th byte
Password count storage address 23 to 16
Baud rate after adjustment Baud rate after adjustment
9th byte 10th byte
Password count storage address 15 to 08
Baud rate after adjustment Baud rate after adjustment
11th byte 12th byte
Password count storage address 07 to 00
Baud rate after adjustment Baud rate after adjustment
BOOT ROM
13th byte 14th byte
Password comparison start address 23 to 16
Baud rate after adjustment Baud rate after adjustment
15th byte 16th byte
Password comparison start address 15 to 08
Baud rate after adjustment Baud rate after adjustment
17th byte 18th byte
Password comparison start address 07 to 00
Baud rate after adjustment Baud rate after adjustment
19th byte : m-th byte
Password string -
Baud rate after adjustment Baud rate after adjustment
m-th + XX byte : n-th - 2 byte n-th - 1 byte
Intel Hex format (binary)
Baud rate after adjustment Baud rate after adjustment
-
Baud rate after adjustment
n-th byte
-
Baud rate after adjustment
RAM
-
The program jumps to the start address of RAM in which the first transferred data is written, and executes itself.
Note 1: "0x** x 3" means that the device goes into an idle state after transmitting 3 bytes of 0x**. For further information, refer to Table 22-18. Note 2: For information on the Intel Hex format, refer to "22.11 Intel Hex Format (Binary)". For information on checksums, refer to "22.10 Checksum (SUM)". For information on passwords, refer to "22.12.1 Passwords". Note 3: If the area 0xFFE0 through 0xFFFF is all 0xFF, password authentication is not performed and, therefore, the password string need not be transmitted. The password count storage address and password comparison start address, however, must be specified, even for a blank product. If the password count storage address and/or password comparison start address are/is incorrect, a password error occurs; the TMP89FM42 stops communication and goes into an idle state. Therefore, if a password error occurs, initialize the TMP89FM42 by using the RESET pin, and restart the serial PROM mode.
RA002
Page 342
TMP89FM42
Note 4: After sending a password string, do not send the end record only. If the TMP89FM42 receives the end record after receiving a password string, it may malfunction. Note 5: If the security program is enabled in flash memory or if a password error occurs, the TMP89FM42 stops communication, and goes into an idle state. Therefore, if a password error occurs, initialize the TMP89FM42 by using the RESET pin, and restart the serial PROM mode. Note 6: If a communication error occurs during the transfer of a password address or a password string, the TMP89FM42 stops communication and goes into an idle state. Therefore, when a password error occurs, initialize the TMP89FM42 by using the RESET pin, and restart the serial PROM mode.
RA002
Page 343
22. Serial PROM Mode
22.8 Operation Commands TMP89FM42
22.8.5 Flash memory SUM output command (operation command: 0x90)
Table 22-11 shows the transfer formats of the flash memory SUM output command. Table 22-11 Transfer Formats of the Flash Memory SUM Output Command
Transfer byte 1st byte 2nd byte Transfer data from the external controller to TMP89FM42 Matching data 1 (0x86 or 0x30) Baud rate Automatic adjustment Baud rate after adjustment Transfer data from TMP89FM42 to the external controller - (Automatic baud rate adjustment) OK: Echo back data (0x86 or 0x30) Error: No data transmitted OK: Echo back data (0x79 or 0xCF) Error: No data transmitted OK: No data transmitted (0x90) Error: 0xA1 x 3, 0xA3 x 3, 0x63 x 3 (note 1) 0x55 : 0xAA: All data are 0xFF. OK: Checksum (high) (note 2) Error: No data transmitted OK: Checksum (low) (note 2) Error: No data transmitted -
3rd byte 4th byte
Matching data 2 (0x79 or 0xCF) -
Baud rate after adjustment Baud rate after adjustment
BOOT ROM
5th byte 6th byte
Operation command data (0x90) -
Baud rate after adjustment Baud rate after adjustment
7th byte
-
Baud rate after adjustment
8th byte
-
Baud rate after adjustment
9th byte
-
Baud rate after adjustment
10th byte
(Wait for the next operation command data)
Baud rate after adjustment
Note 1: "0x** x 3" means that the device goes into an idle state after transmitting 3 bytes of 0x**. For further information, refer to Table 22-18. Note 2: For information on checksums, refer to "22.10 Checksum (SUM)". Note 3: If data to be included in the checksum are all 0xFF, the 7th byte becomes 0xAA. If any one piece of data to be included in the checksum is other than 0xFF, the 7th byte becomes 0x55.
RA002
Page 344
TMP89FM42
22.8.6 Product ID code output command (operation command: 0xC0)
Table 22-12 shows the transfer formats of the product ID code output command. Table 22-12 Transfer Formats of the Product ID Code Output Command
Transfer byte 1st byte 2nd byte Transfer data from the external controller to TMP89FM42 Matching data 1 (0x86 or 0x30) Baud rate Automatic adjustment Baud rate after adjustment Transfer data from TMP89FM42 to the external controller -(Automatic baud rate adjustment) OK: Echo back data (0x86 or 0x30) Error: No data transmitted OK: Echo back data (0x79 or 0xCF) Error: No data transmitted OK: Echo back data (0xC0) Error: 0xA1 x 3, 0xA3 x 3, 0x63 x 3 (note 1) 0x3A 0x13 0x03 0xFD 0x00 0x00 0x00 0x80 Baud rate after adjustment Baud rate after adjustment Baud rate after adjustment Baud rate after adjustment 0x01 0x00 0x80 0x00 0x00 0xFF 0xFF 0x00 0x00 0x60 0x00 0x08 0x3F Start mark Number of transfer data (from 9th to 27th bytes) Length of address (3 bytes) Reserved Reserved Reserved Reserved ROM size code ROM block count (1 block) First address of ROM (upper byte) First address of ROM (middle byte) First address of ROM (lower byte) End address of ROM (upper byte) End address of ROM (middle byte) End address of ROM (lower byte) First address of RAM (upper byte) First address of RAM (middle byte) First address of RAM (lower byte) End address of RAM (upper byte) End address of RAM (middle byte) End address of RAM (lower byte) YYH : Checksum of transfer data (complement of 2 of the sum total from 9th through 27th bytes) -
3rd byte 4th byte
Matching data 2 (0x79 or 0xCF) -
Baud rate after adjustment Baud rate after adjustment
5th byte 6th byte
Operation command data (0xC0) -
Baud rate after adjustment Baud rate after adjustment
7th byte 8th byte 9th byte 10th byte 11th byte 12th byte 13th byte 14th byte (note 2) BOOT ROM 15th byte 16th byte (note 3) 17th byte (note 3) 18th byte (note 3) 19th byte (note 3) 20th byte (note 3) 21st byte (note 3) 22nd byte (note 4) 23rd byte (note 4) 24th byte (note 4) 25th byte (note 4) 26th byte (note 4) 27th byte (note 4)
Baud rate after adjustment Baud rate after adjustment Baud rate after adjustment Baud rate after adjustment Baud rate after adjustment Baud rate after adjustment Baud rate after adjustment
Baud rate after adjustment Baud rate after adjustment Baud rate after adjustment Baud rate after adjustment Baud rate after adjustment Baud rate after adjustment Baud rate after adjustment Baud rate after adjustment Baud rate after adjustment
28th byte
Baud rate after adjustment
0xYY
29th byte
(Wait for the next operation command data)
Baud rate after adjustment
Note 1: "0x** x 3" means that the device goes into an idle state after transmitting 3 bytes of 0x**. For further information, refer to Table 22-18. Note 2: The ROM size code at the 14th byte is shown in Table 22-13. Note 3: 16th through 21st bytes show the range of addresses in flash memory where data can be written.
RA002
Page 345
22. Serial PROM Mode
22.8 Operation Commands TMP89FM42
Note 4: 22nd through 27th bytes show the flash memory area and RAM area that can be used by the RAM loader. Because the range of addresses shown here does not include the work area used by BOOTROM, it is smaller than the size of a RAM built into an actual product.
Table 22-13 ROM Size Code (14th Byte)
7 6 5 ROMSIZE 4 3 2 "0" 1 "0" 0 "0" TMP89FM42 specified value (1000 0000)
ROMSIZE
Data on the flash memory size
00010 : 4Kbytes 00100 : 8Kbytes 01000 : 16Kbytes 10000 : 32Kbytes 11000 : 48Kbytes 11110 : 60Kbytes 10001 : 96Kbytes 11111 : 124Kbytes
Read only
RA002
Page 346
TMP89FM42
22.8.7 Flash memory status output command (0xC3)
Table 22-14 shows the flash memory status output commands. Table 22-14 Flash Memory Status Output Commands
Transfer byte 1st byte 2nd byte Transfer data from the external controller to TMP89FM42 Matching data 1 (0x86 or 0x30) Baud rate Automatic adjustment Baud rate after adjustment Transfer data from TMP89FM42 to the external controller -(Automatic baud rate adjustment) OK: Echo back data (0x86 or 0x30) Error: No data transmitted OK: Echo back data (0x79 or 0xCF) Error: No data transmitted OK: Echo back data (0xC3) Error: 0xA1 x 3, 0xA3 x 3, 0x63 x 3 (note 1) 0x3A 0x04 Start mark Byte count (from 9th through 12th bytes) Status code 1 Reserved Reserved Reserved
3rd byte 4th byte
Matching data 2 (0x79 or 0xCF) -
Baud rate after adjustment Baud rate after adjustment
5th byte 6th byte
Operation command data (0xC3) -
Baud rate after adjustment Baud rate after adjustment
7th byte BOOT ROM 8th byte
Baud rate after adjustment Baud rate after adjustment
9th byte 10th byte 11th byte 12th byte
Baud rate after adjustment Baud rate after adjustment Baud rate after adjustment Baud rate after adjustment
0x00 to 0x7F 0x00 0x00 0x00
13th byte
Baud rate after adjustment
Checksum (complement of 2 of the sum total from 9th through 12th bytes) -
14th byte
(Wait for the next operation command data)
Baud rate after adjustment
Note 1: "xxH x 3" means that the device goes into an idle state after transmitting 3 bytes of xxH. Note 2: For detailed information on the status code 1, refer to "22.8.7.1 Flash memory status code".
RA002
Page 347
22. Serial PROM Mode
22.8 Operation Commands TMP89FM42
22.8.7.1 Flash memory status code
The flash memory status code is 7-byte data. It shows the status of the flash memory security program and that of the address from 0xFFE0 to 0xFFFF. Table 22-15 Flash Memory Status Code
Data 1st 2nd Description Start mark Number of transfer data (4 bytes from 3rd through 6th bytes) Status code Reserved Reserved Reserved In the case of TMP89FM42 0x3A 0x04 0x00 through 0x1F (see information below) 0x00 0x00 0x00 If 3rd data is 0x00: 0x00 If 3rd data is 0x01: 0xFF If 3rd data is 0x02: 0xFE If 3rd data is 0x03: 0xFD :
3rd 4th 5th 6th
7th
Checksum of transfer data (complement of 2 of the sum total of 3rd through 6th bytes)
Status code 1
7 6 5 4 3 EPFC 2 DAFC 1 RPENA 0 BLANK Initial value (**** ****)
EPFC
Password string judgment when the flash memory erase command is executed (status of 0xFFFA) Security program check of the onchip debugging function (OCD) (status of 0xFFFB) Status of the flash memory security program Status of 0xFFE0 through 0xFFFF
0: 1:
To skip the judgment of a password string (to judge PNSA and PCSA only) To judge a password string, PNSA, and PCSA
DAFC
0: 1: 0: 1: 0: 1:
To skip the security program check at the start of OCD To perform the security program check at the start of OCD Status in which the security program is disabled Status in which the security program is enabled If data in the area 0xFFE0 through 0xFFFF are all 0xFF If data in the area 0xFFE0 through 0xFFFF are other than 0xFF
RPENA
BLANK
Restrictions are placed on the execution of some operation commands, depending on the contents of the status code 1. Detailed information on this is shown in the table below. If the security program is enabled, three commands cannot be executed: the flash memory write command, RAM loader mode command, and Sector Erase command. To execute these commands, Chip Erase must be performed on flash memory before they are executed.
RA002
Page 348
TMP89FM42
RPENA
BLANK
EPFC
DAFC
Flash memory overwrite command, flash memory read command, and RAM loader command x Pass Pass x x
Flash memory SUM output command, product ID output command, and status output command
Flash memory erase command Chip erase Pass Pass x x Sector erase x x x
Flash memory security setting command
0 1
0 0
0 0 0
0 0 * * * *
x x Pass Pass Pass Pass
0
1 1 0
1
1 1
Note: : A command can be executed. Pass: A password is required to execute a command. x: A command cannot be executed. (After a command is echoed back, the TMP89FM42 stops communication, and goes into an idle state.)
RA002
Page 349
22. Serial PROM Mode
22.8 Operation Commands TMP89FM42
22.8.8 Mask ROM emulation setting command (0xD0)
Table 22-16 shows the mask ROM emulation setting command. This command is nonfunctional in the TMP89FM42. It becomes functional if used for a product with flash memory of more than 96Kbytes. Table 22-16 Command to Change the Mask ROM Emulation Setting
Number of transfer bytes 1st byte 2nd byte Transfer data from the external controller to TMP89FM42 Matching data 1 (0x86 or 0x30) Baud rate Automatic adjustment Baud rate after adjustment Transfer data from TMP89FM42 to the external controller -(Automatic baud rate adjustment) OK: Echo back data (0x86 or 0x30) Error: No data transmitted OK: Echo back data (0x79 or 0xCF) Error: No data transmitted OK: Echo back data (0xD0) Error: 0xA1 x 3, 0xA3 x 3, 0x63 x 3 (note 1) OK: Echo back data (0xD1) Error: No data transmitted -
3rd byte 4th byte BOOT ROM
Matching data 2 (0x79 or 0xCF) -
Baud rate after adjustment Baud rate after adjustment
5th byte 6th byte
Operation command data (0xD0) -
Baud rate after adjustment Baud rate after adjustment
7th byte 8th byte
Set value
Baud rate after adjustment Baud rate after adjustment
9th byte
(Wait for the next operation command data)
Baud rate after adjustment
Note 1: "xxH x 3" means that the device goes into an idle state after transmitting 3 bytes of xxH.
RA002
Page 350
TMP89FM42
22.8.9 Flash memory security setting command (0xFA)
Table 22-17 shows the flash memory security setting command. Table 22-17 Flash Memory Security Setting Command
Transfer byte 1st byte 2nd byte Transfer data from the external controller to TMP89FM42 Matching data 1 (0x86 or 0x30) Baud rate Automatic adjustment Baud rate after adjustment Transfer data from TMP89FM42 to the external controller - (Automatic baud rate adjustment) OK: Echo back data (0x86 or 0x30) Error: No data transmitted OK: Echo back data (0x79 or 0xCF) Error: No data transmitted OK: Echo back data (0xFA) Error: 0xA1 x 3, 0xA3 x 3, 0x63 x 3 (note 1) OK: No data transmitted Error: No data transmitted OK: No data transmitted Error: No data transmitted OK: No data transmitted Error: No data transmitted OK: No data transmitted Error: No data transmitted OK: No data transmitted Error: No data transmitted OK: No data transmitted Error: No data transmitted OK: No data transmitted Error: No data transmitted OK: 0xFB (note 3) Error: No data transmitted -
3rd byte 4th byte
Matching data 2 (0x79 or 0xCF) -
Baud rate after adjustment Baud rate after adjustment
5th byte 6th byte
Operation command data (0xFA) -
Baud rate after adjustment Baud rate after adjustment
7th byte 8th byte
Password count storage address 23 to 16
Baud rate after adjustment Baud rate after adjustment
9th byte 10th byte
Password count storage address 15 to 08
Baud rate after adjustment Baud rate after adjustment
BOOT ROM
11th byte 12th byte
Password count storage address 07 to 00
Baud rate after adjustment Baud rate after adjustment
13th byte 14th byte
Password comparison start address 23 to 16
Baud rate after adjustment Baud rate after adjustment
15th byte 16th byte
Password comparison start address 15 to 08
Baud rate after adjustment Baud rate after adjustment
17th byte 18th byte
Password comparison start address 07 to 00
Baud rate after adjustment Baud rate after adjustment
19th byte : m-th byte
Password string -
Baud rate after adjustment Baud rate after adjustment
n-th byte
-
Baud rate after adjustment
n-th + 1 byte
(Wait for the next command data)
Baud rate after adjustment
Note 1: "xxH x 3" means that the device goes into an idle state after transmitting 3 bytes of xxH. Note 2: For information on passwords, refer to "22.12.1 Passwords". Note 3: If the flash memory security setting command is executed for a blank product or if a password error occurs for a non-blank product, the TMP89FM42 stops communication and goes into an idle state. Therefore, if a password error occurs, initialize the TMP89FM42 by using the RESET pin, and restart the serial PROM mode. Note 4: If a communication error occurs during the transfer of a password address or password string, the TMP89FM42 stops communication and goes into an idle state. Therefore, if a password error occurs, initialize the TMP89FM42 by using the RESET pin, and restart the serial PROM mode. Note 5: If the flash memory security is not enabled, it becomes possible to read ROM data freely in parallel PROM mode. Make sure that you enable the flash memory security in mass production.
RA002
Page 351
22. Serial PROM Mode
22.9 Error Code TMP89FM42
22.9 Error Code
Table 22-18 shows the error codes that the TMP89FM42 transmits when it detects errors. Table 22-18 Error Codes
Data transmitted 0x63, 0x63, 0x63 0xA1, 0xA1, 0xA1 0xA3, 0xA3, 0xA3 Meaning of error data Operation command error Framing error in the received data Overrun error in the received data
Note: If a password error occurs, the TMP89FM42 does not transmit an error code.
RA002
Page 352
TMP89FM42
22.10Checksum (SUM)
For the following operation commands, a checksum is returned to verify the appropriateness of the result of command execution: - Flash memory erase command (0xF0) - Flash memory write command (0x30) - Flash memory SUM output command (0x30) - Flash memory read command (0x40) - RAM loader command (0x60) - Product ID code output command (0xC0) - Flash memory status output command (0xC3)
22.10.1Calculation method
The checksum (SUM) is calculated with the sum of all bytes, and the obtained result is returned as a word. The data is read in single-byte units, and the calculated result is returned as a word. Example:
0xA1 0xB2 0xC3 0xD4
If the data to be calculated consists of four bytes as shown on the left, the checksum of the data is as follows: 0xA1 + 0xB2 + 0xC3 + 0xD4 = 0x02EA SUM (HIGH)= 0x02 SUM (LOW)= 0xEA
In the case of the product ID code output command and flash memory status output command, however, a different calculation method is used. For more information, refer to Table 22-19.
22.10.2Calculation data
Table 22-19 shows the data for which a checksum is calculated for each command.
Table 22-19 Data for which a Checksum Is Calculated
Operation command Calculation data All data in the erased area of flash memory (whole or part of flash memory) Description When the sector erase is executed, only the erased area is used to calculate the checksum. In the case of the chip erase, an entire area of the flash memory is used. Even if a part of the flash memory is written, the checksum of the entire flash memory area (0x8000 to 0xFFFF) is calculated. The data length, address, record type and checksum in Intel Hex format are not included in the checksum.
Flash memory erase command
Flash memory write command Flash memory SUM output command Flash memory read command Data in the entire area of flash memory
Data in the read area of flash memory RAM data written in the first received RAM address through the last received RAM address 9th through 18th bytes of transferred data The length of data, address, record type and checksum in Intel Hex format are not included in the checksum. For details, refer to "22.8.6 Product ID code output command (operation command: 0xC0)". For details, refer to Table "Table 22-14 Flash Memory Status Output Commands".
RAM loader command
Product ID code output command Flash memory status output command
9th through 12th bytes of transferred data
RA002
Page 353
22. Serial PROM Mode
22.11 Intel Hex Format (Binary) TMP89FM42
22.11Intel Hex Format (Binary)
For the following two commands, the Intel Hex format is used in part of the transfer format: - Flash memory write command (0x30) - RAM loader command (0x60)
For information on the definition of the Intel Hex format, refer to Table 22-20. Data is in binary form. The start mark ":" must be transmitted as binary data of 0x3A. 1. After receiving the checksum of each data record, the TMP89FM42 goes into a wait state and awaits the arrival of the start mark (0x3A ":") of the next data record. Although the external controller transmits data other than 0x3A between records, the TMP89FM42 ignores such data when it is in this wait state. 2. The external controller must be provisioned so that after it transmits the checksum of end record, it goes into a wait state and does not transmit any data until the arrival of 3-byte data (overwrite detection, upper and lower bytes of the checksum). (3-byte data is used if the flash memory write command is used. If the RAM loader command is used, the external controller awaits the arrival of 2-byte data, or upper and lower bytes of the checksum.) 3. If a receiving error or Intel Hex format error occurs, the TMP89FM42 goes into an idle state without returning an error code to the external controller. The Intel Hex format error occurs in the following cases: - If the record type is other than 00h, 01h, or 02h - If a checksum error of the Intel Hex format occurs - If the data length of an extended record (record type = 0x02) is not 0x02 - If the TMP89FM42 receives the data record after receiving an extended record (record type = 0x02) whose segment address is more than 0x2000 - I the data length of the end record (record type = 0x01) is not 0x00 - If the offset address of an extended record (record type = 0x02) is not 0x0000 Table 22-20 Definition of the Intel Hex Format
(1) Start mark (2) Data length (1 byte) (3) Offset address (2 bytes) (4) Record type (1 byte) (5) Data (6) Checksum (1 byte) (2) Data length (3) Offset address (4) Record type (5) Data Complement of 2 of the sum total of the above (2) Data length (3) Offset address (4) Record type Complement of 2 of the sum total of the above (2) Data length (3) Offset address (4) Record type (5) Segment address Complement of 2 of the sum total of the above
Data record 3A (record type = 00)
Number of data in a data field
Starting byte storage address * Specified using big-endian
00
Data (1 to 255 bytes)
End record 3A (record type = 01) 00 00 00 01 None
Extended record 3A (record type = 02) 02 00 00 02
Segment address (2 bytes) * Specified using big-endian
RA002
Page 354
TMP89FM42
22.12Security
In serial PROM mode, two security functions are provided to prohibit illegal memory access attempts by a third party: password and security program functions.
22.12.1Passwords
A password is one of the security functions, and can be used when the TMP89FM42 operates in serial PROM mode or when the on-chip debugging function (hereafter called OCD) is used. Specifically, a password can be established by using data (part of user memory) in flash memory. If a password is established, a password authentication process must be performed to execute the flash memory read command, flash memory write command, and other operation commands. In the case of the OCD, the password authentication process is required prior to the start of the OCD system. In parallel PROM mode, there are no access-related restrictions using a password. To establish the accessrelated restrictions that work in both serial and parallel PROM modes, the security program must be set to an appropriate setting.
22.12.1.1How a password can be specified
With the TMP89FM42, any piece of data in flash memory (8 or more consecutive bytes) can be specified as a password. A password thus specified is authenticated by comparing a password string transmitted by the external controller with the memory data string of MCU where the password is specified. The area where a password can be specified is 0x8000 through 0xFEFF in flash memory.
22.12.1.2Password structure
A password consists of three components: PNSA, PCSA, and a password string. Figure 22-4 shows the password structure (example of a transmitted password). * PNSA (password count storage address) A 3-byte address is specified in the area 0x8000 through 0xFEFF. The memory data of a specified address is the number of bytes of a password string. If the memory data is less than 0x07 or if an address is outside the specified address range, a password error occurs. The memory data specified here is defined as N. * PCSA (password comparison start address) A 3-byte address is specified in the area 0x8000 through 0xFEFF-N. An address thus specified is the starting address to be used to compare with a password string. If an address is outside the specified address range, a password error occurs. * Password string Data of 8 bytes to 255 bytes (=N) must be specified as a password string. Memory data and a password string are compared by a specified number "N" of bytes; a comparison starts at an address specified by PCSA. If there is a mismatch as a result of this comparison or if data of 3 or more consecutive bytes is specified, a password error occurs, and the TMP89FM42 goes into an idle state. In this idle state, external devices cannot communicate with the TMP89FM42. To resume communication, the TMP89FM42 must be restarted in serial PROM mode by using the reset pin.
RA002
Page 355
22. Serial PROM Mode
22.12 Security TMP89FM42
MCU
RXD/SI pin
0x00 0xF0 0x12 0x00 0xF1 0x07 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 PNSA PCSA Password string
Flash memory
0xF012
0x08 0x08 is the number of passwords. Compare
0xF107 0xF108 0xF109 0xF10A 0xF10B Example: PNSA=0xF012 PCSA=0xF107 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 and 0x08 are assumed. 0xF10C 0xF10D 0xF10E
0x01 0x02 0x03 0x04
8 bytes 0x05 0x06 0x07 0x08
Figure 22-4 Password Structure (Example of a Password Transmitted)
RA002
Page 356
TMP89FM42
22.12.1.3Password setting, cancellation and authentication
* Password setting Because a password is created by using part of a user program, a special password setting routine is unnecessary. A password can be set by simply writing a program to flash memory. * Password cancellation To cancel a password, Chip Erase (all erase) must be performed on flash memory. A password is canceled when flash memory is all initialized to 0xFF. * Password authentication If there is data other than 0xFF in any one byte of data written to the address 0xFFE0 through 0xFFFF of the TMP89FM42, a product is considered a non-blank product, and password authentication is required to execute an operation command. In this password authentication process, PNSA, PCSA and a password string are used. An operation command is executed only if a password has been successfully authenticated. If a password is unsuccessfully authenticated, the TMP89FM42 goes into an idle state. If all data written to the address 0xFFE0 through 0xFFFF are 0xFF, a product is considered blank, and no password authentication is performed. To execute some special operation commands, however, PNSA and PCSA are still required (a password string is not required) even if a product is blank. In this case, the addresses defined in Table 22-21 must be selected as PNSA and PCSA. Whether a product is blank or non-blank can be confirmed by executing the status output command. The operation commands that require PNSA and PCSA (password string) for them to be executed are as follows: - Flash memory erase command (0xF0) - Flash memory write command (0x30) - Flash memory read command (0x40) - RAM loader command (0x60) - Flash memory security setting command (0xFA)
22.12.1.4Password values and setting range
A password must be set in accordance with the conditions shown in Table 22-21. If a password created without meeting these conditions is used, a password error occurs. In this case, the TMP89FM42 does not transmit data and goes into an idle state. Table 22-21 Password Values and Setting Range
Password PNSA (password count storage address) PCSA (password comparison start address) N (password count) Password string Blank product (note 1) 0x8000 PNSA 0xFEFF Non-blank product 0x8000 PNSA 0xFEFF
0x8000 PCSA 0xFEFF
0x8000 PCSA 0xFF00 - N
* Not required (notes 4 and 5)
8N Required (note 3)
RA002
Page 357
22. Serial PROM Mode
22.12 Security TMP89FM42
Note 1: *: Don't care. Note 2: When addresses from 0xFFE0 through 0xFFFF are filled with "0xFF", the product is recognized as a blank product. Note 3: The data including the same consecutive data (three or more bytes) cannot be used as a password. (A password error occurs during password authentication. The TMP89FM42 does not transmit any data and goes into an idle state.) Note 4: In flash memory writing mode or RAM loader mode, the blank product receives the Intel Hex format data immediately after receiving PCSA; it does not receive password strings. In this case, the subsequent processing is performed correctly because the TMP89FM42 keeps ignoring incoming data until the start mark (0x3A ":") in the Intel Hex format is detected, even if the external controller transmits the dummy password string. However, if the dummy password string contains "0x3A", it is detected as the start mark erroneously, and the microcontroller enters the halt mode. If this causes a problem, do not transmit the dummy password strings. Note 5: In executing the flash memory erase command, do not transmit a password string to a blank product.
RA002
Page 358
TMP89FM42
22.12.2Security program
The security program can be used in parallel and serial PROM modes and for OCD. It has a special memory for protection, and a special command is required to make this protection setting. If the security program is enabled, the reading or writing of flash memory in parallel PROM mode is prohibited. In serial PROM mode, the read and write of flash memory and other operation commands cannot be used. In performing OCD, two options about system startup are provided: prohibiting the system startup by using an option code and starting the system by password authentication.
22.12.2.1How the security program functions
With the TMP89FM42, you can control the read of flash memory by writing protection-related information to a specially-designed memory. Because protection-related information is written to this speciallydesigned memory, no user memory resource are required.
22.12.2.2Enabling or disabling the security program
* Enabling the security program To enable the security program, execute the flash memory security setting command. * Disabling the security program To disable the security program, execute Chip Erase of the flash memory erase command.
RA002
Page 359
22. Serial PROM Mode
22.12 Security TMP89FM42
22.12.3Option codes
If a specified option code is placed at a specified address inside the interrupt vector area, whether password string authentication is performed or not when executing the flash memory erase command and whether the security program is checked or not when starting OCD can be designated. - Erase password free code EPFC_OP (0xFFFA) If changes are frequently made to a program during software development, there are cases in which a password may get lost. In this case, you can cancel the password string authentication of the flash memory erase command (0xF0) by setting the erase password free code (EPFC_OP). EPFC_OP is assigned to 0xFFFA in the vector area. Allocate 0xFF to this EPFC_OP to cancel the password string of the flash memory erase command (0xF0). It is recommended that the password string authentication of the flash memory erase command (0xF0) be enabled during mass production by allocating data other than 0xFF to EPFC_OP. Only Chip Erase can cancel the password string authentication by using the flash memory erase command. If Sector Erase is executed with EPFC_OP set to 0xFF, the TMP89FM42 goes into an idle state. Commands other than the flash memory erase command cannot cancel the password string authentication. - OCD security program free code DAFC_OP (0xFFFB) With the TMP89FM42, you can enable the security program to prevent illegal access attempts by a third party. If the security program is enabled, restrictions are imposed on operation commands related to memory access, and the startup of OCD. The security program should be usually enabled at the time of shipment. If there is the possibility that the OCD may be used by keeping the contents of memory intact, it is possible to directly start the OCD by setting the OCD security program free code (DAFC_OP) and thereby skipping the security program check (the password string authentication, however, is still required). DAFC_OP is assigned to 0xFFFB in the vector area. To skip the security program check at the startup of the OCD, assign 0xFF to DAFC_OP. In this case, the security program check is not performed, and the OCD can be started by performing only the password string authentication. If DAFC_OP is not 0xFF, whether the OCD can be used or not is determined by the status of the security program. If the OCD is started with the security program enabled, the TMP89FM42 stops communication and goes into an idle state. To use the OCD when the TMP89FM42 is in this idle state, Chip Erase must be executed for flash memory by using the flash memory erase command (0xF0). If the security program is disabled, the OCD can be started by performing only the password string authentication. Table 22-22 Option Codes
Symbol Function Address Set value 0xFF : The password string authentication is skipped (only PNSA and PCSA are authenticated). Other than 0xFF: The password string, PNSA, and PCSA are authenticated. 0xFF: The security program check is skipped. Other than 0xFF: The security program check is performed.
EPFC_OP
Password string authentication when the flash memory erase command is executed
0xFFFA
DAFC_OP
Security program check when the OCD is started
0xFFFB
RA002
Page 360
TMP89FM42
Example :Case in which the password authentication and OCD security program authentication are disabled Vector Section romdata abs = 0xFFFA
DB DB 0xFF 0xFF ; Cancel the password string during the erase operation (EPFC_OP) ; Permit access when the OCD is started (DAFC_OP)
RA002
Page 361
22. Serial PROM Mode
22.12 Security TMP89FM42
22.12.4Recommended settings
Table 22-23 shows the option codes and recommended security program settings. Table 22-23 Option Codes and Recommended Security Program Settings
Device status EPFC_OP (0xFFFA) At the time of debugging during software development DAFC_OP (0xFFFB) Security Program Serial PROM mode Memory read Password string required Erase Parallel PROM mode Memory read OCD Erase
0xFF
0xFF
Disable
Possible
Possible
Possible
Can be used Can be used
0xFF 0xFF Other than 0xFF In quantity production 0xFF Other than 0xFF Other than 0xFF Enable Impossible Password string required Impossible Possible Possible
Cannot be used Can be used Cannot be used
Note 1: In parallel PROM mode, Chip Erase can be performed irrespective of the option code setting. Note 2: If the security program is not enabled in parallel PROM mode, ROM data can be read with no restrictions. Make sure that in parallel PROM mode, you always enable the security program to protect ROM data.
RA002
Page 362
RA002
Start
Setup
Receive data
Received data Receive data = 0x30 S1O mode Transmit S1O data (0x30) Receive data Receive data 0xCF = 0xCF Transmit S1O data (0xCF)
0x86
22.13Flowchart
= 0x86
UART mode
Transmit UART data (0x86)
Receive data
0x79
Receive data
= 0x79
Transmit UART data (0x79)
Receive data
Receive data =D0H
(mask ROM emulation setting command)
Receive data =0x30 (flash memory write command) Receive data =0xF0 (flash memory erase command) Transmit data (0xF0) Transmit data (0x90) Transmit data (0x60) Transmit data (0xC0) Transmit data (0xFA) Transmit data (0xC3)
Receive data =0x90 (flash memory SUM output command)
Receive data =0x60 (RAM loader command)
Receive data =0xC0 (product ID code output command)
Receive data =0xFA (Security Program enable command)
Receive data =0xC3 (status output command)
Receive data =40H (flash memory read command) Transmit data (0xD0) Receive data Transmit data (0x40)
Transmit data (0x30)
Figure 22-5 Flowchart
EPFC-OP = FFH Enabled Not perform password check 0xFF Perform password check Blank check Blank product Blank check Blank product Password check NG Closed loop OK OK Password check Non-blank product Non-blank product Blank check Blank product Non-blank product Password check OK Execute an erase NG Closed loop Receive data
Page 363
Security Program check Disabled Received data 0x20 Calculate checksum Transmit data
(detect all 0xFF)
Security Program check
Security Program check Change FLSCR1 Disabled Enabled
Disabled
Enabled
Blank check
Blank check NG Closed loop Blank product Non-blank product Password check OK NG Closed loop
Blank product
Non-blank product
Password check
NG
OK
Closed loop
< 0x20 = 0xFF EPFC-OP
Receive data Transmit data
(Read data)
Execute a write
Execute a write
Enable Security Program
Security Program check Blank check Chip erase DAFC-OP and EPFC-OP check
(erase the entire area)
0xFF
Transmit data 0x55 : 0xAA: All data are 0xFF.
(detect double writes)
Security Program check Enabled Disabled Sector erase Disable Security Program
(erase in 4KB units)
0x55 : There is no error. 0xAA: There is an error. (Double writes are detected)
Closed loop
Transmit data
Transmit data
Transmit data
(product ID code)
Transmit data
(status)
Transmit data
(checksum of the erased area)
Transmit data
(checksum)
TMP89FM42
(checksum of the entire area)
(checksum of the entire area)
Jump to the user program in RAM
Transmit data (0xFB)
Transmit data (0xD1)
22. Serial PROM Mode
22.14 AC Characteristics (UART) TMP89FM42
22.14AC Characteristics (UART)
Table 22-24 UART Timing-1
Parameter Symbol Clock frequency (fcgck) Approx. 660 Approx. 540 Approx. 300 Approx. 1493340 (32KB) Approx. 160 Approx. 200 Minimum required time At fcgck = 1 MHz 660 s 540 s 300 s At fcgck = 10 MHz 66 s 54 s 30 s
Time from when MCU receives 0x86 to when it echoes back Time from when MCU receives 0x79 to when it echoes back Time from when MCU receives an operation command to when it echoes back Time required to calculate the checksum (flash memory) Time required to calculate the checksum (RAM) Time when MCU receives Intel Hex data to when it transmits overwrite detection data Time from when MCU receives data (number of read bytes) to when it transmits memory data Time from when MCU receives data (mask ROM emulation setting data) to when it echoes back Time required to enable the security program
CMeb1 CMeb2 CMeb3
CMfsm CMrsm CMwr
1.5 s 160 s 200 s
149 ms 16 s 20 s
CMrd
Approx. 430
430 s
43 s
CMem2 CMrp
Approx. 420 Approx. 1080
420 s 1.08 ms
42 s 108 s
Table 22-25 UART Timing-2
Parameter Symbol Clock frequency (fcgck) Minimum required time At fcgck = 1 MHz At fcgck = 10 MHz
Time required to keep MODE and RESET pins at L after power-on Time from when MODE and RESET pins are set to H to the acceptance of RXD Time from when MCU echoes back 0x86 to the acceptance of RXD Time from when MCU echoes back 0x79 to the acceptance of RXD Time from when MCU echoes back an operation command to the acceptance of RXD Time from when the execution of a current command is completed to the acceptance of the next operation command
RSsup RXsup
10 ms 20 ms
CMtr1
Approx. 140
140 s
14 s
CMtr2
Approx. 90
90 s
9 s
CMtr3
Approx. 270
270 s
27 s
CMnx
Approx. 1100
1.1 ms
110 s
RA002
Page 364
TMP89FM42
22.14.1Reset timing
VDD
MODE RSsup RESET (0x86) RXD RXsup (0x79)
(0x86)
(0x79)
TXD CMtr1 CMeb1 CMeb2 CMtr2 CMeb3 Operation command CMtr3
Figure 22-6 Reset Timing
22.14.2Flash memory erase command (0xF0)
PNSA PCSA Password string Area to be erased
[23:16] [15:8] [7:0] [23:16] [15:8] [7:0] RXD (0xF0) TXD CMtr3
Next command RXD [15:8] [7:0] TXD Checksum
CMfsm
CMnx
Figure 22-7 Flash Memory Erase Command
RA002
Page 365
22. Serial PROM Mode
22.14 AC Characteristics (UART) TMP89FM42
22.14.3Flash memory write command (0x30)
PNSA PCSA Password string IntelHex (0x3A)
[23:16] [15:8] [7:0] [23:16] [15:8] [7:0] RXD (0x30) TXD CMtr3 IntelHex(End Record) (0x00) (0x00) (0x01) (0xFF) RXD (0x55) or (0xAA) TXD Overwrite CMwr detection
Next command
[15:8] [7:0]
CMfsm
Checksum
CMnx
Figure 22-8 Flash Memory Write Command
22.14.4Flash memory read command (0x40)
PNSA PCSA Password string Read start address [23:16] [15:8] [7:0]
[23:16] [15:8] [7:0] [23:16] [15:8] [7:0] RXD (0x40) TXD CMtr3 Number of read bytes [23:16] [15:8] [7:0] RXD
Next command
[15:8] [7:0] TXD Memory data Checksum
CMrd
CMnx
Figure 22-9 Flash Memory Read Command
RA002
Page 366
TMP89FM42
22.14.5RAM loader command (0x60)
PNSA PCSA Password string IntelHex (0x3A)
[23:16] [15:8] [7:0] [23:16] [15:8] [7:0] RXD (0x60) TXD CMtr3 IntelHex(End Record) (0x00) (0x00) (0x01) (0xFF) RXD
Next command
[15:8] [7:0] TXD Checksum
CMrsm
CMnx
Figure 22-10 RAM Loader Command
22.14.6Flash memory SUM output command (0x90)
Next command RXD (0x90) TXD FF check Checksum (0x55) or (0xAA) [15:8] [7:0]
CMfsm
CMnx
Figure 22-11 Flash Memory SUM Output Command
22.14.7Product ID code output command (0xC0)
Next command RXD (0xC0) TXD Product ID code
CMnx
Figure 22-12 Product ID Code Output Command
RA002
Page 367
22. Serial PROM Mode
22.14 AC Characteristics (UART) TMP89FM42
22.14.8Flash memory status output command (0xC3)
Next command RXD (0xC3) TXD Status code
CMnx
Figure 22-13 Flash Memory Status Output Command
22.14.9Mask ROM emulation setting command (0xD0) Figure 22-14 Mask ROM Emulation Setting Command
22.14.10Flash memory security setting command (0xFA)
PNSA PCSA Password string
[23:16] [15:8] [7:0] [23:16] [15:8] [7:0] RXD (0xFA) TXD CMtr3
Next command RXD 0xFB TXD Echo back CMnx
CMrp
Figure 22-15 Flash Memory Security Setting Command
RA002
Page 368
TMP89FM42
22.15Revision History
Rev Added P20 and P21 description to TXD0 and RXD0 pin. RA002
Description
"Table 22-24 UART Timing-1", "Table 22-25 UART Timing-2" Deleted VDD and Topr condition. These condition is defined in Electrical Characteristics.
RA002
Page 369
22. Serial PROM Mode
22.15 Revision History TMP89FM42
RA002
Page 370
TMP89FM42
23. On-chip Debug Function (OCD)
The TMP89FM42 has an on-chip debug function. Using a combination of this function and the TOSHIBA on-chip debug emulator RTE870/C1, the user is able to perform software debugging in the on-board environment. This emulator can be operated from a debugger installed on a PC so that the emulation and debugging functions of an application program can be used to modify a program or for other purposes. This chapter describes the control pins needed to use the on-chip debug function and how a target system is connected to the on-chip debug function. For more detailed information on how to use the on-chip debug emulator RTE870/C1, refer to the emulator operating manual.
23.1 Features
The on-chip debug function of the TMP89FM42 has the following features: * Debugging can be performed in much the same way as when a microcontroller packaged with the MCU is used. * The debugging function can be realized using two communication control pins. * Useful on-chip debug functions include the following: - 8 breaks function are provided (one of which can also be used as an event function). - A trace function that allows the newest two branch instructions to be stored in real time is provided. - Functions to display active memory and to overwrite active memory are provided. * Built-in flash memory can be erased and written.
23.2 Control Pins
The on-chip debug function uses two pins for communication and four pins for power supply, reset and mode control. The pins used for the on-chip debug function are shown in Table 23-1. Ports P20 and P21 are used as communication control pins of the on-chip debug function. If the on-chip debug emulator RTE870/C1 is used, therefore, the port functions and the functions of UART0 and SIO0, which are also used as ports, cannot be debugged. Table 23-1 Pins Used for the On-chip Debug Function
Pin name (during on-chip debugging) OCDCK OCDIO
RESET
Input/output Input I/O Input Input Power supply Power supply I/O Input
Function Communication control pin (clock control) Communication control pin (data control) (Note 1) Reset control pin Mode control pin 4.5 V to 5.5 V (note 1)
Pin name (in MCU mode) P20 / TXD0 / SO0 P21 / RXD0 / SI0
RESET
MODE VDD
MODE
VSS Input and output ports other than P20 and P21 XIN XOUT
0V
Can be used for an application in a target system
To be connected to an oscillator to put these pins in a state of self-oscillation Output
Note 1: To use all on-chip debug functions, the power supply voltage must be within the range 4.5 V to 5.5 V. If it is within the range 2.2 V to 4.5 V, functional limitations occur with some of the debug functions. For more detailed information, refer to the emulator operating manual.
RA000
Page 371
23. On-chip Debug Function (OCD)
23.3 How to Connect the On-chip Debug Emulator to a Target System TMP89FM42
23.3 How to Connect the On-chip Debug Emulator to a Target System
To use the on-chip debug function, the specific pins on a target system must be connected to an external debugging system. The on-chip debug emulator RTE870/C1 can be connected to a target system via an interface control cable. TOSHIBA provides a connector for this interface control cable as an accessory tool. Mounting this connector on a target system will make it easier to use the on-chip debug function. The connection between the on-chip debug emulator RTE870/C1 and a target system is shown in Figure 23-1.
Level Shifter (provided power supply by target system) Control Circuit (provided power supply by bus power)
VDD (Note 3) VDD OCDCK (P20) OCDIO (P21) (Note 2)
TMP89FM42
Other parts (Note 1)
RESET control
Interface control cable
USB connection
RESET MODE XIN XOUT VSS
During on-chip debugging MCU mode (Note 3)
Target system
Connectors
On-chip debug emulator RTE870/C1
PC (host system)
Figure 23-1 How the On-chip Debug Emulator RTE870/C1 Is Connected to a Target System
Note 1: Ports P20 and P21 are used as communication control pins of the on-chip debug function. If the on-chip debug emulator RTE870/C1 is used, therefore, the port functions and the functions of UART0 and SIO0, which are also used as ports, cannot be debugged. If the emulator is disconnected to be used as a single MCU, the functions of ports P20 and P21 can be used. To use the on-chip debug function, however, P20 and P21 should be disconnected using a jumper, switch, etc. if there is the possibility of other parts affecting the communication control. Note 2: If the reset control circuit on an application board affects the control of the on-chip debug function, it must be disconnected using a jumper, switch, etc. Note 3: The power supply voltage VDD must be provided by a target system. The VDD pin is connected to the emulator so that the level of voltage appropriate for driving communication pins can be obtained by using the power supply of a target system. The connection of the VDD pin is for receiving the power supply voltage, not for supplying it from the emulator side to a target system.
23.4 Security
The TMP89FM42 provides two security functions to prevent the on-chip debug function from being used through illegal memory access attempted by a third person: a password function and a Security Program function. If a password is set on the TMP89FM42, it is necessary to authenticate the password for using the on-chip debug function. By setting both a password and the Security Program on the TMP89FM42, it is possible to prohibit the use of all onchip debug functions. Furthermore, by using the option code, the on-chip debug function only can be used even if the Security Program is enabled. However, to use the on-chip debug function in this setting, a password authentication process is required. For information on how to set a password and to enable the read protection and option code, refer to "Serial PROM Mode". RA000 Page 372
TMP89FM42
24. Input/Output Circuit
24.1 Control Pins
The input/output circuitries of the TMP89FM42 control pins are shown below.
Control pin XIN XOUT XTIN XTOUT
RESET
I/O Input Output Input Output Input
Circuitry Refer to the P0 ports in the chapter of Input/Output Ports.
Remarks
Refer to the P0 ports in the chapter of Input/Output Ports. Refer to the P1 ports in the chapter of Input/Output Ports.
R
MODE
Input
R = 100 (typ.)
RA000
Page 373
24. Input/Output Circuit
24.1 Control Pins TMP89FM42
RA000
Page 374
TMP89FM42
25. Electrical Characteristics
25.1 Absolute Maximum Ratings
The absolute maximum ratings are rated values which must not be exceeded during operation, even for an instant. Any one of the ratings must not be exceeded. If any absolute maximum rating is exceeded, a device may break down or its performance may be degraded, causing it to catch fire or explode resulting in injury to the user. Thus, when designing products which include this device, ensure that no absolute maximum rating value will ever be exceeded.
(VSS = 0 V) Parameter Supply voltage Symbol VDD VIN1 Input voltage VIN2 VIN3 Output voltage VOUT1 IOUT1 IOUT2 Output current (per pin) IOUT3 IOUT4 IOUT1 IOUT2 Output current (total) IOUT3 IOUT4 Power dissipation (Topr = 85C) Soldering temperature (time) Storage temperature Operating temperature PD Tsld Tstg Topr P0, P1, P2, P4, P74 to P77, P8, P9 (tri-state port) P70 to P73, PB (large current port) 60 120 250 260 (10 s) -55 to 125 -40 to 85 C mW P0, P1, P2, P4, P74 to P77, P8, P9 (tri-state port) P70 to P73, PB (large current port) P0, P1, P2 (excluding P23 and P24), P4, P7, P8, P9, PB (tri-state port) P0, P1, P2, P4, P9 (pull-up resistor) 3.2 30 mA -30 -4 P0, P1, P2 (excluding P23 and P24), P4, P7, P8, P9, PB (tri-state port) P0, P1, P2, P4, P9 (pull-up resistor) P0, P1, P2 (excluding P23 and P24), P4, P7, P8, P9, PB (tri-state port) P23, P24 (sink open drain port) AIN0 to AIN7 (analog input voltage) Pins Ratings -0.3 to 6.0 -0.3 to VDD + 0.3 -0.3 to VDD + 0.3 -0.3 to AVDD + 0.3 -0.3 to VDD + 0.3 -1.8 -0.4 V V Unit V
RA002
Page 375
25. Electrical Characteristics
25.2 Operating Conditions TMP89FM42
25.2 Operating Conditions
The operating conditions for a device are operating conditions under which it can be guaranteed that the device will operate as specified. If the device is used under operating conditions other than the operating conditions (supply voltage, operating temperature range, specified AC/DC values etc.), malfunction may occur. Thus, when designing products which include this device, ensure that the operating conditions for the device are always adhered to.
25.2.1 MCU mode (Flash Programming or erasing)
(VSS = 0 V, Topr = -10 to 40C) Parameter Supply voltage Input high level VIH2 VIL1 Input low level VIL2 fc Clock frequency fcgck Hysteresis input XIN, XOUT VDD 4.5 V 1.0 0.25 Hysteresis input MODE pin VDD 4.5 V Symbol VDD VIH1 MODE pin Pins Condition NORMAL1, 2 modes VDD 4.5 V Min 4.5 VDD x 0.70 VDD x 0.75 0 Max 5.5 VDD V VDD x 0.30 VDD x 0.25 10.0 MHz 10.0 Unit
[V] 5.5 4.5
[V] 5.5 4.5
1
0.250
10
[MHz]
10
[MHz]
Gear clock(fcgck) frequency range
High-frequency clock(fc) frequency range
Figure 25-1 Clock gear (fcgck) and High-frequency clock (fc)
RA002
Page 376
TMP89FM42
25.2.2 MCU mode (Except Flash Programming or erasing)
(VSS = 0 V, Topr = -40 to 85C) Parameter Symbol Pins fc = 10.0 MHz fc = 8.0 MHz fcgck = 10.0 MHz Supply voltage VDD fcgck = 4.2 MHz fcgck = 2.0 MHz fs = 32.768 kHz STOP mode VIH1 Input high level VIH2 VIH3 VIL1 Input low level VIL2 VIL3 fc XIN, XOUT MODE pin Hysteresis input VDD < 4.5 V VDD = 2.2 to 5.5 V VDD = 2.7 to 5.5 V VDD = 2.2 to 5.5 V Clock frequency fcgck VDD = 2.7 to 5.5 V VDD = 4.3 to 5.5 V fs XTIN, XTOUT VDD = 2.2 to 5.5 V 30.0 0.25 1.0 1.0 MODE pin Hysteresis input VDD < 4.5 V VDD 4.5 V 0 VDD 4.5 V VDD x 0.70 VDD x 0.75 VDD x 0.90 VDD x 0.30 VDD x 0.25 VDD x 0.10 8.0 10.0 2.0 4.2 10.0 34.0 kHz MHz V VDD SLOW1, 2 modes SLEEP0, 1 modes 2.2 NORMAL1, 2 modes IDLE0, 1, 2 modes Condition Min 2.7 2.2 4.3 2.7 5.5 V Max Unit
[V] 5.5 4.3
[V] 5.5 4.3
2.7 2.2
2.7 2.2
4.2
4 4.2
8 8.4
2
1
2
0.250
10
10
[MHz]
[MHz]
Gear clock(fcgck) frequency range
High-frequency clock(fc) frequency range fc, fc/2 or fc/4 can be used as gear clock (fcgck). Only fc/2 or fc/4 can be used as gear clock (fcgck). Only fc/4 can be used as gear clock (fcgck).
Figure 25-2 Clock gear (fcgck) and High-frequency clock (fc)
RA002
Page 377
25. Electrical Characteristics
25.2 Operating Conditions TMP89FM42
25.2.3 Serial PROM mode
(VSS = 0 V, Topr = -10 to 40C) Parameter Supply voltage Input high voltage VIH2 VIL1 Input low voltage VIL2 fc Clock frequency fcgck Hysteresis input XIN, XOUT VDD 4.5 V 1.0 0.25 Hysteresis input MODE pin VDD 4.5 V Symbol VDD VIH1 MODE pin Pins Condition NORMAL1, 2 modes VDD 4.5 V Min 4.5 VDD x 0.70 VDD x 0.75 0 Max 5.5 VDD V VDD x 0.30 VDD x 0.25 10.0 MHz 10.0 Unit
[V] 5.5 4.5
[V] 5.5 4.5
10
1
0.250
[MHz]
10
[MHz]
Gear clock(fcgck) frequency range
High-frequency clock(fc) frequency range
Figure 25-3 Clock gear (fcgck) and High-frequency clock (fc)
RA002
Page 378
TMP89FM42
25.3 DC Characteristics
(VSS = 0 V, Topr = -40 to 85C) Parameter Hysteresis voltage Symbol VHS IIN1 Input current IIN2 IIN3 RIN2 Input resistance RIN3 ILO1 Output leakage current ILO2 Output high voltage Output low voltage Output low current VOH VOL IOL Pins Hysteresis input MODE P0, P1, P2, P4, P5, P7, P8, P9, PB
RESET, STOP RESET pull-up
Condition
Min -
Typ. 0.9
Max -
Unit V
VDD = 5.5 V VIN = VMODE = 5.5 V/0 V - - 2 A
100 VDD = 5.5 V, VIN = VMODE = 0 V 30 VDD = 5.5 V, VOUT = 5.5 V VDD = 5.5 V, VOUT = 5.5 V/0 V VDD = 4.5 V, IOH = -0.7 mA VDD = 4.5 V, IOL = 1.6 mA VDD = 4.5 V, VOL = 1.0 V - -
220 50 - - - - 20
500 k 100 2 A 2 - V 0.4 - mA
P0, P1, P2 (excluding P23 and P24), P4, P9 pull-up P23, P24 (skin open drain port) P0, P1, P2 (excluding P23 and P24), P4, P5, P7, P8, P9, PB (tristate port) Except P23, P24, XOUT, XTOUT Except XOUT, XTOUT P70 to P73, PB (Large current port)
4.1 - -
Note 1: Typical values show those at Topr = 25C and VDD = 5.0 V. Note 2: Input current IIN3 : The current through pull-up resistor is not included.
RA002
Page 379
25. Electrical Characteristics
25.3 DC Characteristics TMP89FM42
(VSS = 0 V, Topr = -40 to 85C) Parameter Symbol Pins VDD = 5.5 V VIN = 5.3 V/0.2 V VMODE=5.3V/0.1V fcgck = 10.0 MHz fs = 32.768 kHz Condition When a program operates on flash memory When a program operates on RAM Min - Typ. Max Unit
Supply current in NORMAL 1, 2 modes (Note 7)
14.5
20.0
- -
9.5
12.5
Supply current in IDLE0, 1, 2 modes
5.5
7.5 mA
Supply current in NORMAL 1, 2 modes (Note 7) IDD (Note 8)
VDD = 5.5 V VIN = 5.3 V/0.2 V VMODE=5.3V/0.1V fcgck = 8.0 MHz fs = 32.768 kHz
When a program operates on flash memory When a program operates on RAM
-
13
-
- -
8
- -
Supply current in IDLE0, 1, 2 modes
4.5
Supply current in SLOW1 mode (Notes 5 and 7)
When a program operates on flash memory VDD = 3.0 V VIN = 2.8 V/0.2 V VMODE=2.8V/0.1V fs = 32.768 kHz When a program operates on RAM
-
20
39
- - -
11
30
Supply current in SLEEP1 mode Supply current in SLEEP0 mode Supply current in STOP mode
10
24
A
9
22
VDD = 5.5 V VIN = 5.3 V/0.2 V VMODE=5.3V/0.1V VDD = 5.5 V VIN = 5.3 V/0.2 V - - - 10 25
Peak current of intermittent operation (Notes 7 and 9)
VMODE=5.3V/0.1V IDDRP-P VDD = 3.0V VIN = 2.8 V/0.2 V VMODE=2.8V/0.1V
When a program operates on flash memory or when data is being read from flash memory
10
-
2
-
mA
Current for writing to flash memory, erasing and security program (Notes 4, 8 and 9)
VDD = 5.5 V IDDEW VIN = 5.3 V/0.2 V VMODE=5.3V/0.1V - 26 -
Note 1: Typical values shown are Topr = 25C and VDD = 5.0 V, unless otherwise specified. Note 2: IDD does not include IREF. It is the electrical current in the state in which the peripheral circuitry has been operated. Note 3: VIN : The input voltage on the pin except MODE pin, VMODE : The input voltage on the MODE pin Note 4: When performing a write or erase on the flash memory or activating a security program in the flash memory, make sure that the operating temperature Topr is within the range -10C to 40C. If the temperature is outside this range, the resultant performance cannot be guaranteed. Note 5: In SLOW1 mode, the difference between the peak current and the average current becomes large. Note 6: Each supply current in SLOW2 mode is equivalent to that in IDLE0, IDLE1 and IDLE2 modes. Note 7: When a program operates in the flash memory or when data is being read from the flash memory, the flash memory operates intermittently, and a peak current flows, as shown in Figure 25-4. In this case, the supply current IDD (in NORMAL1, NORMAL2 and SLOW1 modes) is defined as the sum of the average peak current and MCU current. Note 8: If a write or erase is performed on the flash memory or a security program is enabled in the flash memory, an instantaneous peak current flows, as shown in Figure 25-5. Note 9: The circuit of a power supply must be designed such as to enable the supply of a peak current. This peak current causes the supply voltage in the device to fluctuate. Connect a bypass capacitor of about 0.1 F near the power supply of the device to stabilize its operation.
RA002
Page 380
TMP89FM42
1 machine cycle Program counter (PC) I DDP-P
[mA]
n
n+1
n+2
n+3 Momentary flash current Sum of average momentary flash current and MCU current
Maximum current Typical current MCU current
Figure 25-4 Intermittent Operation of Flash Memory
1 machine cycle Program counter (PC)
Internal data bus
Internal write signal
Last write cycle of each of the Byte Program, Security Program, Chip Erase and Sector Erase
TBD, TSCE
I DDEW
[mA]
Figure 25-5 Current When an Erase or Write is Being Performed on the Flash Memory
RA002
Page 381
25. Electrical Characteristics
25.4 AD Conversion Characteristics TMP89FM42
25.4 AD Conversion Characteristics
(VSS = 0.0 V, 4.5 V VDD 5.5 V, Topr = -40 to 85C) Parameter Analog reference voltage / Power supply voltage of analog control circuit Analog input voltage range Power supply current of analog reference voltage Non-linearity error Zero point error Full scale error Total error VDD = AVDD / VAREF = 5.0 V VSS = 0.0V Symbol VAREF / AVDD VAIN IREF VDD = AVDD / VAREF = 5.5 V VSS = 0.0 V VSS - - - - - Condition Min Typ. VDD V - 0.6 - - - - VAREF 1.0 3 3 LSB 3 3 mA Max Unit
(VSS = 0.0 V, 2.7 V VDD < 4.5 V, Topr = -40 to 85C) Parameter Analog reference voltage / Power supply voltage of analog control circuit Analog input voltage range Power supply current of analog reference voltage Non-linearity error Zero point error Full scale error Total error VDD = AVDD / VAREF = 2.7 V VSS = 0.0V Symbol VAREF / AVDD VAIN IREF VDD = AVDD / VAREF = 4.5 V VSS = 0.0 V VSS - - - - - Condition Min Typ. VDD V - 0.5 - - - - VAREF 0.8 3 3 LSB 3 3 mA Max Unit
(VSS = 0.0 V, 2.2 V VDD < 2.7 V, Topr = -40 to 85C) Parameter Analog reference voltage / Power supply voltage of analog control circuit Analog input voltage range Power supply current of analog reference voltage Non-linearity error Zero point error Full scale error Total error VDD = AVDD / VAREF = 2.2 V, VSS = 0.0 V Symbol VAREF / AVDD VAIN IREF VDD = AVDD / VAREF = 2.7 V VSS = 0.0 V VSS - - - - - Condition Min Typ. VDD V - 0.3 - - - - VAREF 0.5 4 4 LSB 4 4 mA Max Unit
Note 1: The total error includes all errors except a quantization error, and is defined as the maximum deviation from the ideal conversion line. Note 2: Conversion times differ with variation in the power supply voltage. Note 3: The voltage to be input to the AIN input pin must be within the range VAREF to VSS. If a voltage outside this range is input, converted values will become indeterminate, and converted values of other channels will be affected. Note 4: If the AD converter is not used, fix the VAREF/AVDD pin to the VDD level.
RA002
Page 382
TMP89FM42
25.5 Power-on Reset Circuit Characteristics
Power supply voltage (VDD) Operating voltage
VPROFF VPRON
t VDD
tPPW tPRON tPROFF
Power-on reset signal Warm-up counter start
Warm-up counter clock
tPWUP
CPU and peripheral circuit reset signal
Figure 25-6 Power-on Reset Operation Timing
Note: Care must be taken in system designing since the power-on reset circuit may not fulfill its functions due to the fluctuations in the power supply voltage (VDD).
(VSS=0 V, Topr = -40 to 85C) Symbol VPROFF VPRON tPROFF tPRON tPRW tPWUP tVDD Parameter Power-on reset releasing voltageNote Power-on reset detecting voltageNote Power-on reset releasing response time Power-on reset detecting response time Power-on reset minimum pulse width Warming-up time after a reset is cleared Power supply rise time Min. 1.85 1.75 - - 1.0 - - Typ. 2.02 1.85 0.01 0.01 - 102 x 29/fc - Max. 2.19 V 1.95 0.1 0.1 - - 5 s ms ms Unit
Note 1: Because the power-on reset releasing voltage and the power-on reset detecting voltage change relative to one another, the detected voltage will never become inverted. Note 2: A clock output by an oscillating circuit is used as the input clock for a warming-up counter. Because the oscillation frequency does not stabilize until an oscillating circuit stabilizes, some errors may be included in the warming-up time. Note 3: Boost the power supply voltage such that tVDD becomes smaller that tPWUP.
RA002
Page 383
25. Electrical Characteristics
25.6 Voltage Detecting Circuit Characteristics TMP89FM42
25.6 Voltage Detecting Circuit Characteristics
Power supply voltage (VDD)
Operating voltage Level of detected voltage
tVLTPW tVLTON Signal to request the voltage detection interrupt Voltage detection reset signal tVLTOFF
Figure 25-7 Operation Timing of the Voltage Detecting Circuit
Note: Care must be taken in system designing since the power-on reset circuit may not fulfill its functions due to the fluctuations in the power supply voltage (VDD).
(VSS = 0 V, Topr = -40 to 85C) Symbol tVLTOFF tVLTON tVLTPW Parameter Voltage detection releasing response time Voltage detecting detection response time Voltage detecting minimum pulse width Min. - - 1.0 Typ. 0.01 0.01 - Max. 0.1 0.1 - ms Unit
RA002
Page 384
TMP89FM42
25.7 AC Characteristics
25.7.1 MCU mode (Flash programming or erasing)
(VSS = 0 V, VDD = 4.5 V to 5.5 V, Topr = -10 to 40C) Parameter Symbol Condition NORMAL1, 2 modes 0.100 Machine cycle time tcy IDLE0, 1, 2 modes SLOW1, 2 modes 117.6 SLEEP0, 1 modes High-level clock pulse width Low-level clock pulse width High-level clock pulse width Low-level clock pulse width tWCH tWCL tWSH tWSL For external clock operation (XIN input). fc = 10.0 MHz For external clock operation (XTIN input) fs = 32.768 kHz - 50.0 - ns - 133.3 Min Typ. - Max 4 s Unit
-
15.26
-
s
25.7.2 MCU mode (Except Flash Programming or erasing)
(VSS = 0 V, VDD = 4.3 V to 5.5 V, Topr = -40 to 85C) Parameter Symbol Condition NORMAL1, 2 modes 0.100 Machine cycle time tcy IDLE0, 1, 2 modes SLOW1, 2 modes 117.6 SLEEP0, 1 modes High-level clock pulse width Low-level clock pulse width High-level clock pulse width Low-level clock pulse width tWCH tWCL tWSH tWSL For external clock operation (XIN input). fc = 10.0 MHz For external clock operation (XTIN input) fs = 32.768 kHz - 50.0 - ns - 133.3 Min Typ. - Max 4 s Unit
-
15.26
-
s
(VSS = 0 V, VDD = 2.7 V to 4.3 V, Topr = -40 to 85C) Parameter Symbol Condition NORMAL1, 2 modes 0.238 Machine cycle time tcy IDLE0, 1, 2 modes SLOW1, 2 modes 117.6 SLEEP0, 1 modes High-level clock pulse width Low-level clock pulse width High-level clock pulse width Low-level clock pulse width tWCH tWCL tWSH tWSL For external clock operation (XIN input). fc = 10.0 MHz For external clock operation (XTIN input) fs = 32.768 kHz - 50.0 - ns - 133.3 Min Typ. - Max 4 s Unit
-
15.26
-
s
RA002
Page 385
25. Electrical Characteristics
25.8 Flash Characteristics TMP89FM42
(VSS = 0 V, VDD = 2.2 V to 2.7 V, Topr = -40 to 85C) Parameter Symbol Condition NORMAL1, 2 modes 0.500 Machine cycle time tcy IDLE0, 1, 2 modes SLOW1, 2 modes 117.6 SLEEP0, 1 modes High-level clock pulse width Low-level clock pulse width High-level clock pulse width Low-level clock pulse width tWCH tWCL tWSH tWSL For external clock operation (XIN input). fc = 8.0 MHz For external clock operation (XTIN input) fs = 32.768 kHz - 62.5 - ns - 133.3 Min Typ. - Max 4 s Unit
-
15.26
-
s
25.7.3 Serial PROM mode
(VSS = 0 V, VDD = 4.5 V to 5.5 V, Topr = -10 to 40C) Parameter Symbol Condition NORMAL1, 2 modes 0.100 Machine cycle time tcy IDLE0, 1, 2 modes SLOW1, 2 modes 117.6 SLEEP0, 1 modes High-level clock pulse width Low-level clock pulse width High-level clock pulse width Low-level clock pulse width tWCH tWCL tWSH tWSL For external clock operation (XIN input). fc = 10.0 MHz For external clock operation (XTIN input) fs = 32.768 kHz - 50.0 - ns - 133.3 Min Typ. - Max 4 s Unit
-
15.26
-
s
25.8 Flash Characteristics
25.8.1 Write characteristics
(VSS = 0 V, Topr = -10 to 40C) Parameter Number of guaranteed writes to flash memory Flash memory write time Chip erase Flash memory erase time Sector erase Symbol Condition - - - - Min - - - - Typ. 100 40 30 ms 30 Max Times s
RA002
Page 386
TMP89FM42
25.9 Recommended Oscillating Condition- 1
XIN
XOUT
XTIN
XTOUT
C1
C2
C1
C2
(1) High-frequency oscillation
(2) Low-frequency oscillation
Note 1: To ensure stable oscillation, the resonator position, load capacitance, etc. must be appropriate. Because these factors are greatly affected by board patterns, please be sure to evaluate operation on the board on which the device will actually be mounted. Note 2: The product numbers and specifications of the resonators supplied by Murata Manufacturing Co., Ltd. are subject to change. For up to date information, please refer to the following http://www.murata.com
RA002
Page 387
25. Electrical Characteristics
25.10 Handling Precaution TMP89FM42
25.10Handling Precaution
- The solderability test conditions for lead-free products (indicated by the suffix G in product name) are shown below. 1. When using the Sn-37Pb solder bath Solder bath temperature = 230C Dipping time = 5 seconds Number of times = once R-type flux used 2. When using the Sn-3.0Ag-0.5Cu solder bath Solder bath temperature = 245C Dipping time = 5 seconds Number of times = once R-type flux used
Note: The pass criteron of the above test is as follows: Solderability rate until forming 95% - When using the device (oscillator) in places exposed to high electric fields such as cathode-ray tubes, we recommend electrically shielding the package in order to maintain normal operating condition.
RA002
Page 388
TMP89FM42
25.11Revision History
Rev
Description The maximum value of the operation frequency is changed from 8MHz to 10MHz.
RA001
Added figure for "Clock gear (fcgck) and High-frequency clock (fc)". "25.4 AD Conversion Characteristics" Fixed spec.
RA002
"25.5 Power-on Reset Circuit Characteristics" Revised table (IPWUP Unit) from "ms" to "s".
RA002
Page 389
25. Electrical Characteristics
25.11 Revision History TMP89FM42
RA002
Page 390
TMP89FM42
26. Package Dimensions
LQFP44-P-1010-0.80B Rev 01
Unit: mm
12.0 0.2 10.0 0.2
10.0 0.2 1.0TYP 0.8 0.1 0.05 1.4 0.05 0.25 0.37
0.08 0.07
0.2
0.6 0.15
RA000
0.145
0.055
Page 391
1.6MAX
12.0 0.2
26. Package Dimensions
TMP89FM42
RA000
Page 392
This is a technical document that describes the operating functions and electrical specifications of the 8-bit microcontroller series TLCS-870/C1 (LSI). Toshiba provides a variety of development tools and basic software to enable efficient software development. These development tools have specifications that support advances in microcomputer hardware (LSI) and can be used extensively. Both the hardware and software are supported continuously with version updates. The recent advances in CMOS LSI production technology have been phenomenal and microcomputer systems for LSI design are constantly being improved. The products described in this document may also be revised in the future. Be sure to check the latest specifications before using. Toshiba is developing highly integrated, high-performance microcomputers using advanced MOS production technology and especially well proven CMOS technology. We are prepared to meet the requests for custom packaging for a variety of application areas. We are confident that our products can satisfy your application needs now and in the future.


▲Up To Search▲   

 
Price & Availability of TMP89FM42

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X